How to create a WPF combobox flat style?

放肆的年华 提交于 2019-12-01 17:32:50

Do you mean toolbar combobox toolbar style? Try this

<ComboBox Style="{StaticResource {x:Static ToolBar.ComboBoxStyleKey}}"/>

Here's a link to the standard combobox styles and templates: http://msdn.microsoft.com/en-us/library/ms752094.aspx.

You should be able to add a style, similar to the following that makes the ComboBox flat (it may need some tweaking):

<Style x:Key="CustomComboBox"  TargetType="{x:Type ComboBox}">
    <Setter Property="HorizontalAlignment" Value="Stretch"/>
    <Setter Property="VerticalAlignment" Value="Top"/>
    <Setter Property="MinWidth" Value="60"/>
    <Setter Property="UIElement.SnapsToDevicePixels" Value="True"/>
    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
    <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
    <Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
    <Setter Property="TextElement.Foreground" Value="Black"/>
    <Setter Property="FrameworkElement.FocusVisualStyle" Value="{x:Null}"/>
    <Setter Property="BorderBrush" Value="Black"/>
    <Setter Property="BorderThickness" Value="1" />
    <Setter Property="Background" Value="White" />      
</Style>

For checking over 3rd party .Net assemblies for control templates and styles, you can use Reflector (which now costs), or Telerik's JustDecompile (free). There are likely to be other tools similar to these, but these are all you need (especially Reflector).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!