San*_*sal 2 c# wpf xaml combobox
我正在尝试为WPF ComboBox创建一个自定义样式,但每当我这样做时,下拉列表都没有打开,我想使用从我的按钮样式创建的以下XAML代码,但是将它移植到ComboBox控件,我该怎么办?这样做是为了让下拉确实显示并让我能够改变鼠标悬停颜色.
<ControlTemplate TargetType="Button">
<Border Name="border"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="1"
Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers>
<!--TODO: Set the right colors-->
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="BorderBrush" Value="#FFC6C6C6" />
<Setter Property="Foreground" Value="#FF333333" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Foreground" Value="#FF666666" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="#FFCCCCCC"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3872 次 |
| 最近记录: |