Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a WPF combobox flat style?

I want to create a flat style template for WPF combobox which looks like a combobox in Visual Studio 2010. Also I want to use Visual Studio brushes for this template.

Visial Studio 2010 combobox style

Does anybody help me to find the way? Are there any completed templates? Also does anybody know something about an application that can get controls templates from other applications?

like image 658
pingvinius Avatar asked Aug 30 '11 10:08

pingvinius


2 Answers

Do you mean toolbar combobox toolbar style? Try this

<ComboBox Style="{StaticResource {x:Static ToolBar.ComboBoxStyleKey}}"/>
like image 198
polteennick Avatar answered Sep 21 '22 11:09

polteennick


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>
like image 39
Josh Avatar answered Sep 25 '22 11:09

Josh