【发布时间】:2016-08-15 13:26:29
【问题描述】:
问题
我在我的 WPF 应用程序中使用 MahApps,但是当我添加一个控件时,它使用 MahApps 控件。我想使用默认的组合框和样式。
有没有一种方法可以让我按照我需要的方式使用默认组合框和样式?
代码
我尝试添加Style={x:Null},但问题是我无法将我的样式Background="Transparent" 添加到该控件。
我也尝试添加自定义样式,但问题是它从控件中删除了下拉图标。
<Style x:Key="Combobox" TargetType="{x:Type ComboBox}">
<Setter Property="BorderThickness" Value="2"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBox}">
<Border x:Name="bg" BorderBrush="#858585" BorderThickness="2" CornerRadius="2">
<ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="BorderBrush" TargetName="bg" Value="#ec122c"/>
<Setter Property="BorderThickness" TargetName="bg" Value="2"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
有人可以帮忙吗?
【问题讨论】:
标签: wpf combobox mahapps.metro