现在ListBoxItem 需要统一的属性,以及在鼠标点击和鼠标覆盖改变背景,字体的大小,颜色等等功能。
下面代码简单的实现了这些功能
<Style x:Key="listboxItem" TargetType="ListBoxItem">
<Setter Property="Height" Value="25"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="Foreground" Value="#ffb4b4b4"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Foreground" Value="#ffe59e00"/>
<Setter Property="FontSize" Value="14"></Setter>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Foreground" Value="#ffdcdcdc"/>
<Setter Property="FontSize" Value="13"></Setter>
</Trigger>
</Style.Triggers>
</Style>
<ListBoxItem Style="{StaticResource listboxItem}" Name="***" Content="***" />