关于上一个问题,我有以下禁用蓝色背景的代码:
<ListBox Background="Transparent" BorderBrush="Transparent">
<ListBox.Style>
<Style>
<Style.Resources>
<!-- Background of selected item when focussed -->
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
<!-- Background of selected item when not focussed -->
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
</Style.Resources>
</Style>
</ListBox.Style>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Margin="5" BorderThickness="2" BorderBrush="LightGray" CornerRadius="5">
<Expander IsExpanded="True" Background="#f7f7f7">
<!-- Content -->
</Expander>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ListBox>
我注意到的是,现在所有内容中的组合框之类的东西也都具有相同的透明选择样式。我需要做什么才能使选择仅对 ListBoxItem 透明而不对其内容透明?