WPF ComboBox ControlTemplate后台问题
这是 ComboBox
的 ControlTemplate
的示例。
我尝试设置背景< /strong> / 添加触发器,以在组合框聚焦时更改背景(例如使用 Tab 键), 都没有成功。 我什至不明白为什么默认情况下不包含它! (与原始通用模板相比)
This is an example of a ComboBox
's ControlTemplate
.
I've tried to set the Background / add a trigger to change the background when the ComboBox is focused (with a tab key for example),
both without success.
I don't even understand why it isn't included by default !
(compared to the original generic template)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的意思是在 ComboBoxItem 聚焦时更改其背景吗?更改整个 ComboBox 的背景是不正常的。请记住,可编辑组合框的模板是不同的。
从您引用的模板来看,Background 属性用于 ComboBox 下拉列表。所以你的触发器需要瞄准最外面的网格。您是否尝试过添加这样的触发器?
Do you mean change the background of the ComboBoxItem when it is focused? Its not normal to change the background of an entire ComboBox. Keep in mind that the template is different for editable ComboBoxes.
From looking at the template you referenced, the Background property is used for the ComboBox dropdown. So you're trigger needs to target that outter most Grid. Did you try adding triggers like these?