是否有人能够告诉我,以下源代码中的内容是什么?
(我正在尝试在右键单击时禁用我的listBox项目上的灰色突出显示)
<ListBox ItemsSource="{Binding TotoList}"
VerticalAlignment="Stretch"
VerticalContentAlignment="Top">
<ListBox.Style>
<Style TargetType="{x:Type ListBox}">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}"
Color="Transparent" />
</Style.Resources>
</Style>
</ListBox.Style>
<ListBox.Template>
<ControlTemplate>
<Border BorderBrush="DarkGray"
BorderThickness="0">
<ItemsPresenter />
</Border>
</ControlTemplate>
</ListBox.Template>
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Transparent"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<Grid Width="120">
<Label Content="{Binding Name}"
HorizontalAlignment="Left"
Margin="5,0,0,0"/>
</Grid>
<Border.Style>
<Style TargetType="Border">
<Style.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Background"
Value="Transparent" />
</Trigger>
</Style.Triggers>
</Style>
</Border.Style>
<Border.ContextMenu>
<ContextMenu>
<MenuItem Header="Remove"
Click="removeToto">
</MenuItem>
</ContextMenu>
</Border.ContextMenu>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
当右键单击listBox项目以删除它时,该项目以灰色突出显示...
答案 0 :(得分:0)
还将以下资源添加到ListBox资源中。以下键负责非活动选择画笔。
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}"
Color="Transparent" />