如何在Mouseover上增加ListViewItem Opacity?

时间:2013-01-29 03:55:39

标签: wpf xaml listview mouseevent opacity

我正在调整Opacity中自定义控件项的ListView,并希望将它们设置回完全不透明度OnMouseOver。我可以将它们调暗OnMouseOver,但我无法增加Opacity。我猜这与ListView ControlTemplate有关。任何帮助表示感到非常沮丧:

<ListView Background="Transparent" BorderBrush="Transparent" Grid.Row="0" VerticalAlignment="Top">
        <ListView.ItemContainerStyle>
            <Style TargetType="{x:Type ListViewItem}">
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Opacity" Value=".9"/>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </ListView.ItemContainerStyle>
    <notify:NotificationInfo/>
</ListView>

1 个答案:

答案 0 :(得分:0)

我不知道这是否有用:

<ListView>
    <ListViewItem>Johan</ListViewItem>
    <ListViewItem>Ray</ListViewItem>
    <ListView.ItemContainerStyle>
        <Style TargetType="{x:Type ListViewItem}">
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Opacity" Value=".9"/>
                </Trigger>
                <Trigger Property="IsMouseOver" Value="False">
                    <Setter Property="Opacity" Value=".2"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </ListView.ItemContainerStyle>
</ListView>

感觉不太好。