[英]WPF ListBox selection not grayed out when losing focus
I want to visualize a listbox item highlighted when selected, regardless the focus of the parent listbox. 无论父列表框的焦点如何,我都希望可视化选中时突出显示的列表框项目。
In this example I have two listboxes. 在此示例中,我有两个列表框。 In both listboxes the first (and only) element is selected.
在两个列表框中,第一个(也是唯一一个)元素被选中。 ListBox 1 does NOT have Focus.
列表框1没有焦点。 ListBox 2 does have focus.
ListBox 2确实具有焦点。 I want to have identical highlighting color.
我想要具有相同的突出显示颜色。
How do I achieve this in a custom listbox / listboxitem style? 如何以自定义列表框/列表框样式实现此目的?
Found the answer myself in Blend. 在Blend中自己找到答案。
<SolidColorBrush x:Key="Item.SelectedInactive.Background" Color="#3D26A0DA"/>
<SolidColorBrush x:Key="Item.SelectedInactive.Border" Color="#FF26A0DA"/>
<SolidColorBrush x:Key="Item.SelectedActive.Background" Color="#3D26A0DA"/>
<SolidColorBrush x:Key="Item.SelectedActive.Border" Color="#FF26A0DA"/>
I now use the same borders and backgrounds (active / inactive). 我现在使用相同的边框和背景(有效/无效)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.