0


WPF中的ListBox样式(没被选择有点模糊,选中清晰,鼠标进入变大,移出变小)

<Style TargetType="ListBoxItem">
    <!--  没有被选中就是有点模糊  -->
    <Setter Property="Opacity" Value="0.5" />
    <Setter Property="MaxHeight" Value="75" />
    
    <Style.Triggers>
        <!--  触发器设置选中了就取消模糊变正常  -->
        <Trigger Property="IsSelected" Value="True">
            <Setter Property="Opacity" Value="1.0" />
        </Trigger>
        <!--  鼠标进入  -->
        <EventTrigger RoutedEvent="Mouse.MouseEnter">
            <EventTrigger.Actions>
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation
                            Storyboard.TargetProperty="MaxHeight"
                            To="90"
                            Duration="0:0:0.2" />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger.Actions>
        </EventTrigger>
        <!--  鼠标离开  -->
        <EventTrigger RoutedEvent="Mouse.MouseLeave">
            <EventTrigger.Actions>
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetProperty="MaxHeight" Duration="0:0:1" />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger.Actions>
        </EventTrigger>
    </Style.Triggers>
</Style>

相关:http://t.csdnimg.cn/sOlIv

标签: ui wpf c#

本文转载自: https://blog.csdn.net/weixin_46407807/article/details/136635105
版权归原作者 励志35岁去越南躺平的造砖核动黑马程序猿 所有, 如有侵权,请联系我们删除。

“WPF中的ListBox样式(没被选择有点模糊,选中清晰,鼠标进入变大,移出变小)”的评论:

还没有评论