聚焦时改变组合框的外观

时间:2015-03-24 16:39:33

标签: c# wpf

如何在获得焦点时更改组合框的外观? 组合框不可编辑,当你收到焦点时,它必须保持这样:

https://magnusmontin.files.wordpress.com/2014/04/combobox.png?w=525&h=143

以下是代码:

http://pastebin.com/yej92T14

2 个答案:

答案 0 :(得分:0)

将此添加到控件模板触发器中:

 <Trigger Property="IsFocused" Value="True">
         <Setter TargetName="DropDownBorder" Property="Background" Value="Red"/>
         <!-- Change appearance here -->                   
 </Trigger>

这会使焦点变红(第2行)

答案 1 :(得分:0)

成功!

我创建了一个黄色的新ControlTemplate,并在IsFocused事件中更改了

以下是解决方案:

<Trigger Property="IsFocused" Value="true">
    <Setter TargetName="ToggleButton" Property="Template" Value="{StaticResource ComboBoxToggleButtonFundo}" />
</Trigger>
相关问题