博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
wpf动画同步闪烁
阅读量:4501 次
发布时间:2019-06-08

本文共 2022 字,大约阅读时间需要 6 分钟。

1    public class BlinkAnimation : Animatable 2     { 3         ///  4         /// 单例,保持所有闪烁的动画同步 5         ///  6         public static readonly BlinkAnimation Instance = new BlinkAnimation(); 7  8         public double BlinkOpacity 9         {10             get { return (double)GetValue(BlinkOpacityProperty); }11             set { SetValue(BlinkOpacityProperty, value); }12         }13 14         // Using a DependencyProperty as the backing store for BlinkOpacity.  This enables animation, styling, binding, etc...15         public static readonly DependencyProperty BlinkOpacityProperty =16             DependencyProperty.Register("BlinkOpacity", typeof(double), typeof(BlinkAnimation), new PropertyMetadata(0.0));17 18 19 20         /// 21         /// 闪烁动画,用于动画同步22         /// 23         public BlinkAnimation()24         {25             try26             {27                 DoubleAnimationUsingKeyFrames doubleAnimation = new DoubleAnimationUsingKeyFrames28                 {29                     RepeatBehavior = RepeatBehavior.Forever,30                     Duration = TimeSpan.FromSeconds(1.5)31                 };32 33                 DiscreteDoubleKeyFrame ddkf1 = new DiscreteDoubleKeyFrame(0.0, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)));34                 DiscreteDoubleKeyFrame ddkf2 = new DiscreteDoubleKeyFrame(1.0, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.75)));35 36                 doubleAnimation.KeyFrames.Add(ddkf1);37                 doubleAnimation.KeyFrames.Add(ddkf2);38 39                 if (BlinkOpacityProperty!=null)40                 {41                      BeginAnimation(BlinkOpacityProperty, doubleAnimation);42                 } 43             }44             catch (Exception)45             {46                 // ignored47             }48         }49 50         protected override Freezable CreateInstanceCore()51         {52             return Instance;53         }54     }

 

 

使用方法:

1   
2
1   

 

感谢阅读

转载于:https://www.cnblogs.com/chlm/p/8352043.html

你可能感兴趣的文章
GCD Operation 等线程知识点 在IOS Developer Library 中的位置
查看>>
1284 2 3 5 7的倍数 分类: 51nod ...
查看>>
r函数知识总结
查看>>
dds数字信号发生器
查看>>
Java简介(1)
查看>>
ui-router 1.0 003 lazyloading
查看>>
Lua编程
查看>>
程序中堆和栈的区别
查看>>
imx6 lvds 代码分析
查看>>
通过代码创建联系人
查看>>
大数智能未来
查看>>
jQuery插件实现网页底部自动加载-类似新浪微博
查看>>
学生空间bug report
查看>>
shanchushanchu
查看>>
linux下使用autoconf制作Makefile
查看>>
快来秒杀我
查看>>
Python_阻塞IO、非阻塞IO、IO多路复用
查看>>
爬虫超时解决的方法
查看>>
网络技术和科技革命周末随想
查看>>
Codeforces 10C Digital Root 法冠军
查看>>