<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Border Name="Bd"
Background="{TemplateBinding Background}">
<GridViewRowPresenter
HorizontalAlignment="Stretch"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Width="Auto" Margin="0" Content="{TemplateBinding Content}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Background" Value="#FF404040"/>
<Setter Property="Foreground" Value="#FFFFC400"/>
<Setter TargetName="Bd" Property="BorderBrush" Value="#FFFFC400"/>
<Setter TargetName="Bd" Property="BorderThickness" Value="0,1,0,1"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="true" />
<Condition Property="IsSelected" Value="false"/>
</MultiTrigger.Conditions>
<Setter Property="Background" Value="#FF666666"/>
<Setter Property="Foreground" Value="LightGray"/>
<Setter Property="BorderBrush" Value="#FFFFC400"/>
<Setter Property="BorderThickness" Value="0,1,0,1"/>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
wpf 设置listview样式,包括选中,悬浮样式如图
最新推荐文章于 2024-08-14 08:40:54 发布