如何创建WPF组合框平面样式?

pin*_*ius 6 wpf combobox styles controltemplate

我想为WPF组合框创建一个平面样式模板,它看起来像Visual Studio 2010中的组合框.此外,我想使用Visual Studio画笔来完成此模板.

Visial Studio 2010组合框样式

有人帮我找路吗?有没有完成的模板?也有人知道一个可以从其他应用程序获取控件模板的应用程序吗?

小智 19

你的意思是工具栏组合框工具栏样式?试试这个

<ComboBox Style="{StaticResource {x:Static ToolBar.ComboBoxStyleKey}}"/>
Run Code Online (Sandbox Code Playgroud)


Jos*_*osh 7

这是标准组合框样式和模板的链接:http: //msdn.microsoft.com/en-us/library/ms752094.aspx.

您应该能够添加一个样式,类似于以下使ComboBox变平(可能需要一些调整):

<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>
Run Code Online (Sandbox Code Playgroud)


slu*_*ter 0

要检查第 3 方 .Net 程序集的控件模板和样式,您可以使用Reflector(现在需要付费)或Telerik 的 JustDecompile(免费)。可能还有与这些类似的其他工具,但这些就是您所需要的(尤其是 Reflector)。