zoukankan      html  css  js  c++  java
  • WPF 鼠标滑过列表渐变效果

    今天闲来无事,看到很多web的动画效果,用WPF模仿着也写了个简单的。简单的给listboxItem加了个样式。里面就是一个动画,写的比较粗糙。

    <Style x:Key="stye1" TargetType="{x:Type ListBoxItem}">
                <Setter Property="Foreground" Value="Snow" />
                <Setter Property="Background" Value="Transparent" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ListBoxItem}">
                            <Border Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}">
                                <ContentPresenter />
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <!--  鼠标悬停  -->
                                    <Setter Property="Background" Value="Black" />
                                    <!--  value中写你要的颜色的值  -->
                                </Trigger>
    
                                <EventTrigger RoutedEvent="Mouse.MouseLeave">
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <ColorAnimation Duration="0:0:0.4"
                                                            From="#AA000000"
                                                            Storyboard.TargetProperty="(ListBoxItem.Background).(SolidColorBrush.Color)"
                                                            To="Transparent" />
                                        </Storyboard>
                                    </BeginStoryboard>
                                </EventTrigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

    再来看看界面效果

     

  • 相关阅读:
    文件操作
    匿名函数
    函数
    运算符
    (模板)扩展kmp算法(luoguP5410)
    poj2406(求字符串的周期,kmp算法next数组的应用)
    poj1961(kmp算法next数组应用)
    hdoj1711(kmp算法)
    (模板)poj3461(kmp模板题)
    fzu1704(高斯消元法解异或方程组+高精度输出)
  • 原文地址:https://www.cnblogs.com/garysun90/p/5567849.html
Copyright © 2011-2022 走看看