本文介绍了为什么设置InactiveSelectionHighlightBrushKey不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
i搜索更改ListBoxItem背面颜色并保持此选择颜色,即使控件失去焦点
i找到这样的解决方案:
hi everyone,
i searched for changing ListBoxItem back color and persisting this selection color even if the control lost focus
i found the solution like this :
<ListBox Name="lst" >
<ListBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
Color="Black"/>
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}"
Color="Black"/>
</ListBox.Resources>
<ListBoxItem>battekha</ListBoxItem>
<ListBoxItem>mooza</ListBoxItem>
<ListBoxItem>manga</ListBoxItem>
</ListBox>
但它仍然不适用于我
活动或非活动时的选择与默认保持相同
任何想法为什么?
but it still doesn't work for me
the selection while active or inactive remains the same as default
any idea why ?
推荐答案
<Grid>
<ListBox Name="lst" >
<ListBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
Color="Black"/>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}"
Color="Black"/>
<Style TargetType="{x:Type ListBoxItem}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="White"/>
</Trigger>
</Style.Triggers>
</Style>
</ListBox.Resources>
<ListBoxItem>battekha</ListBoxItem>
<ListBoxItem>mooza</ListBoxItem>
<ListBoxItem>manga</ListBoxItem>
</ListBox>
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="107,157,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
</Grid>
这篇关于为什么设置InactiveSelectionHighlightBrushKey不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!