我能够设定的ListView非活动选择色彩WPF ListView的非活动选择颜色和元素的字体颜色
我用溶液在以下问题描述
WPF ListView Inactive Selection Color
我需要改变的选择的字体颜色非活动元素,有没有简单的方法来完成这个?
谢谢
我能够设定的ListView非活动选择色彩WPF ListView的非活动选择颜色和元素的字体颜色
我用溶液在以下问题描述
WPF ListView Inactive Selection Color
我需要改变的选择的字体颜色非活动元素,有没有简单的方法来完成这个?
谢谢
不幸的是,你不能因为它适用时该项目未选择使用SystemColors.ControlTextBrushKey
,或当它被选中,但不活跃(你的问题读取,仿佛你是只在后者的兴趣)。但是,你可以这样做:
<ListBox ...>
<ListBox.Resources>
<!-- this customizes the background color when the item is selected but inactive -->
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}">Red</SolidColorBrush>
</ListBox.Resources>
<ListBox.ItemContainerStyle>
<Style>
<Style.Triggers>
<!-- this customizes the foreground color when the item is selected but inactive -->
<Trigger Property="Selector.IsSelected" Value="True">
<Setter Property="TextElement.Foreground" Value="Blue"/>
</Trigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
对于我这个工作 - 在活动和非活动列表框,选定itemss是相同的前景色和背景色。
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="DodgerBlue"/>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="White"/>
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="DodgerBlue"/>
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}" Color="White"/>
</Style.Resources>
</Style>
</ListBox.ItemContainerStyle>
谢谢你的回答,但不幸的是所选元素变成灰色,在列表框的时候失去重点:( 我想前景是白色和蓝色的背景,选择元素的时候,但无效。 – 2009-04-27 15:33:52
更新我的答案。 – 2009-04-27 16:16:38