我正在尝试隐藏WPF
我创建了一个新的 WPF 项目并编辑了
很不幸,这并不起作用,窗口看起来像这样: 有什么想法我做错了什么?如何去除所选项目和悬停在其上的蓝色颜色?
ListBox
中指示选择的视觉提示。 此答案 建议通过覆盖该 ListBox
的 SystemColors
来实现这一点。我创建了一个新的 WPF 项目并编辑了
MainWindow.xaml
,如下所示:<Window x:Class="WpfListboxWithoutSelection.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfListboxWithoutSelection"
xmlns:s="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
Title="MainWindow" Height="150" Width="325">
<Grid>
<ListBox>
<ListBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
</ListBox.Resources>
<s:String>Item 1</s:String>
<s:String>Item 2</s:String>
<s:String>Item 3</s:String>
</ListBox>
</Grid>
</Window>
很不幸,这并不起作用,窗口看起来像这样: 有什么想法我做错了什么?如何去除所选项目和悬停在其上的蓝色颜色?