0
我有下面的XAML代碼:在列表視圖中選擇的項目設置樣式
<ListView.ItemTemplate>
<DataTemplate>
<Border x:Name="SetBorder" Background="Transparent">
<Grid Margin="5" Width="130">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Image Source="{Binding Path=Code, Converter={StaticResource SetCodeToImageConverter}}" MaxWidth="105">
<Image.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=SetBorder, Path=Selector.IsSelectionActive}" Value="True">
<Setter Property="Image.Opacity" Value="1" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=SetBorder, Path=IsMouseOver}" Value="True">
<Setter Property="Image.Opacity" Value="1" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=SetBorder, Path=IsMouseOver}" Value="False">
<Setter Property="Image.Opacity" Value="0.5" />
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
<TextBlock Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center"
Text="{Binding Path=Name}" TextWrapping="WrapWithOverflow" MaxWidth="120">
</TextBlock>
</Grid>
</Border>
</DataTemplate>
我想我的形象的不透明度設置爲1,當鼠標移動到(該部分作品)並選擇該項目時(該部分不起作用)。有任何想法嗎 ?