我有一个问题,我的列表视图中取消选择的项目在我取消选择后不显示“IsMouseOver”的颜色,除非我选择其他内容然后选择它。在我的 ItemContainerStyle 中,我将焦点/非焦点的默认颜色设置为透明,因为我想定义自己的值。谁能看看这个并告诉我为什么“IsMouseOver”对取消选择的项目不起作用?
xml:
<ListView Name="lstPhoneCarrier" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="408" Height="145"
ItemsSource="{Binding ShowAllCarrierInfo, Mode=TwoWay}"
ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Visible"
SelectionMode="Single">
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
</Style.Resources>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Yellow" />
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate>
<Label x:Name="lblCarrier" HorizontalAlignment="Left">
<Label.Content>
<StackPanel Orientation="Horizontal">
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}-{1}">
<Binding Path="Name" />
<Binding Path="Description" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</StackPanel>
</Label.Content>
</Label>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=CarrierSelected}" Value="True" >
<Setter TargetName="lblCarrier" Property="Background" Value="Pink" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListView.ItemTemplate>