zoukankan      html  css  js  c++  java
  • WPF使用Storyboard做个带旋转特效的关闭按钮

    见过迅雷7右边广告的关闭按钮,鼠标移上去的话有个旋转90度的效果,感觉挺酷的,于是用WPF也实现了一下。很简单,定义几行XAML就搞定了。WPF做这种效果还是很好使的~~

    用SL封装了个效果:

     <Image Width="20" Height="20" Source="image\close.png" 
                         ToolTip
    ="关闭"
                       Opacity
    ="0.5" Canvas.Left="720" Canvas.Top="3" 
                       MouseLeftButtonDown
    ="Close_MouseLeftButtonDown">
                    <Image.RenderTransform>
                        <RotateTransform x:Name="imgTransform"
                                         CenterX
    ="10"
                                         CenterY
    ="10"
                                         Angle
    ="0"/>
                    </Image.RenderTransform>
                    <Image.Triggers>
                        <EventTrigger RoutedEvent="Image.MouseEnter">
                            <BeginStoryboard   HandoffBehavior="Compose"  >
                                <Storyboard >
                                    <DoubleAnimation
                        
    Storyboard.TargetName="imgTransform"
                            Storyboard.TargetProperty
    ="Angle" 
                            By
    ="90" Duration="0:0:.2" 
                            
    />
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </Image>
    其中给图片定义个旋转的变化,然后给鼠标进入事件添加一个触发器。当鼠标进入的时候触发器触发故事板在0.2秒时间内使图片以中心为圆点旋转90度。SO EASY!!

    QQ群:1022985150 VX:kklldog 一起探讨学习.NET技术
    作者:Agile.Zhou(kklldog)
    出处:http://www.cnblogs.com/kklldog/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    hdu 1599 find the mincost route (最小环与floyd算法)
    hdu 3371(prim算法)
    hdu 1598 find the most comfortable road (并查集+枚举)
    hdu 1879 继续畅通工程 (并查集+最小生成树)
    hdu 1272 小希的迷宫(并查集+最小生成树+队列)
    UVA 156 Ananagrams ---map
    POJ 3597 Polygon Division (DP)
    poj 3735 Training little cats 矩阵快速幂+稀疏矩阵乘法优化
    poj 3734 Blocks 快速幂+费马小定理+组合数学
    CodeForces 407B Long Path (DP)
  • 原文地址:https://www.cnblogs.com/kklldog/p/2790083.html
Copyright © 2011-2022 走看看