2
我有一個包含GridView的ListView。我正在嘗試更改所選項目的背景以及懸停的項目背景。經過一番搜索之後,我發現控制模板與觸發器一起使用,但它們並未開火。ListView項目控件模板觸發器沒有觸發
<ListView x:Name="TestListView" Margin="0,0.333,0.333,0" Grid.Row="1" Grid.Column="1" SelectedIndex="0" MouseDoubleClick="Song_List_DoubleClick" SelectionMode="Single" Background="#FF181818" Foreground="White" BorderBrush="#FF181818">
<ListView.View>
<GridView>
<GridViewColumn Header="A" Width="120" DisplayMemberBinding="{Binding A}" />
<GridViewColumn Header="B" Width="50" DisplayMemberBinding="{Binding B}" />
<GridViewColumn Header="C" Width="150" DisplayMemberBinding="{Binding C}" />
<GridViewColumn Header="D" Width="150" DisplayMemberBinding="{Binding D}" />
</GridView>
</ListView.View>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#282828"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#333333" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView>
任何幫助是非常讚賞的屏幕截圖。謝謝!
感謝@Sakura。 :) 有用。 – HaloMediaz
不客氣:) – Sakura