【问题标题】:WPF ComboBox ControlTemplate Background problemWPF ComboBox ControlTemplate 后台问题
【发布时间】:2010-03-08 14:28:01
【问题描述】:

这是ComboBoxControlTemplate示例

CLICK HERE

我尝试设置背景 / 添加触发器以在组合框聚焦时更改背景(使用tab键例如), 两者都没有成功。 我什至不明白为什么默认情况下不包含它! (与原始通用模板相比)

【问题讨论】:

    标签: wpf combobox background controltemplate controltemplates


    【解决方案1】:

    你的意思是当 ComboBoxItem 获得焦点时改变它的背景?改变整个 ComboBox 的背景是不正常的。请记住,可编辑组合框的模板是不同的。

    通过查看您引用的模板,Background 属性用于 ComboBox 下拉菜单。所以你的触发器需要瞄准最外面的网格。您是否尝试添加此类触发器?

    <Trigger Property="IsKeyboardFocusWithin" Value="True">
        <Setter TargetName="[outtermostgrid]" Property="Background" Value="Red" />
    </Trigger>
    <Trigger Property="IsDropdownOpen" Value="True">
        <Setter TargetName="[outtermostgrid]" Property="Background" Value="Red" />
    </Trigger>
    

    【讨论】:

    • 好吧,我将触发器添加到了有效的 ToggleButton ControlTemplate 的边框。你是指哪个网格? ComboBox ControlTemplate 中可视化树中的第一个 Grid?
    猜你喜欢
    • 2013-05-23
    • 1970-01-01
    • 2011-05-06
    • 1970-01-01
    • 1970-01-01
    • 2010-10-11
    • 2011-07-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多