だから私は自分の問題の解決策を見つけるために数時間努力してきました。インターネット上で、うまくいくと言われている方法を見つけることができます(リンク)。
しかし、試してみた後、リストボックスのエントリを1つ選択すると、テキストのみが(Foregroundプロパティを介して)青に変わりますが、行は赤に色付けされません。私が間違っていることについて何か考えがありますか?
<Style x:Key="BPFStandardListBoxItem" TargetType="{x:Type ListBoxItem}">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Red"/>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Purple"/>
</Style.Resources>
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border Name="Border" Padding="2" SnapsToDevicePixels="true">
<ContentPresenter />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="Blue" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Cursor" Value="Hand" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>