- <Style x:Key="UserItemContainerStyle" TargetType="ListBoxItem">
- <Style.Resources>
- <!--SelectedItem with focus-->
- <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="LightBlue" Opacity=".4"/>
- <!--SelectedItem without focus-->
- <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="LightBlue" Opacity=".4"/>
- </Style.Resources>
- <!-- 设置触发器 -->
- <Style.Triggers>
- <Trigger Property="IsMouseOver" Value="true">
- <Setter Property="Background" Value="#efefef"/>
- <Setter Property="Foreground" Value="Red"/>
- </Trigger>
- <Trigger Property="IsFocused" Value="true">
- <Setter Property="Background" Value="Coral"/>
- <Setter Property="Foreground" Value="Red"/>
- </Trigger>
- </Style.Triggers>
- </Style>
原文地址:http://blog.csdn.net/leftfist/article/details/27544233
其他方法:https://www.mgenware.com/blog/?p=180