WPF 动画闪烁效果

一、按钮外边缘呼吸闪烁

点击触发效果;
代码:

<Window x:Class="WpfApp1.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WpfApp1"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><Window.Resources><Style x:Key="ResourcesButtonStyle" TargetType="{x:Type FrameworkElement}" ><Setter Property="Width" Value="60"/><Setter Property="Height" Value="40"/><Setter Property="Effect"><Setter.Value><DropShadowEffect x:Name="OSE" BlurRadius="10" Color="Lime" Direction="0"   Opacity="1" RenderingBias="Performance" ShadowDepth="0" ><Storyboard.TargetProperty>BlurRadius</Storyboard.TargetProperty></DropShadowEffect></Setter.Value></Setter><Style.Triggers><EventTrigger RoutedEvent="GotFocus"><BeginStoryboard><Storyboard><DoubleAnimation Storyboard.TargetProperty="(FrameworkElement.Effect).(DropShadowEffect.BlurRadius)" From="0" To="100" BeginTime="00:00:00" Duration="00:00:01" AutoReverse="True"  RepeatBehavior="Forever"/><ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Effect).(DropShadowEffect.Color)"RepeatBehavior="Forever" AutoReverse="True"><EasingColorKeyFrame KeyTime="0" Value="Yellow"/><EasingColorKeyFrame KeyTime="0:0:0.4" Value="Purple"/><EasingColorKeyFrame KeyTime="0:0:0.8" Value="Green"/><EasingColorKeyFrame KeyTime="0:0:1.2" Value="DarkCyan"/><EasingColorKeyFrame KeyTime="0:0:1.6" Value="Black"/><EasingColorKeyFrame KeyTime="0:0:2.0" Value="OrangeRed"/><EasingColorKeyFrame KeyTime="0:0:2.4" Value="Violet"/><EasingColorKeyFrame KeyTime="0:0:2.8" Value="CornflowerBlue"/><EasingColorKeyFrame KeyTime="0:0:3.2" Value="Lime"/><EasingColorKeyFrame KeyTime="0:0:3.6" Value="Azure"/><EasingColorKeyFrame KeyTime="0:0:4.0" Value="Turquoise"/><EasingColorKeyFrame KeyTime="0:0:4.4" Value="Tomato"/></ColorAnimationUsingKeyFrames></Storyboard></BeginStoryboard></EventTrigger></Style.Triggers></Style></Window.Resources><Grid><Button Content="Hello" Background="#007ACC" Height="30" Width="50" Style="{StaticResource ResourcesButtonStyle}"/></Grid>
</Window>

二、实心圆颜色呼吸渐变
效果:

代码:

<Window x:Class="WpfApp1.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WpfApp1"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><Window.Resources><Storyboard x:Key="OnLoaded" RepeatBehavior="Forever" AutoReverse="True"  ><ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="Ellipse"><EasingColorKeyFrame KeyTime="0:0:1" Value="#990033"/></ColorAnimationUsingKeyFrames></Storyboard></Window.Resources><Window.Triggers><EventTrigger RoutedEvent="FrameworkElement.Loaded"><BeginStoryboard  Storyboard="{StaticResource OnLoaded}"/></EventTrigger></Window.Triggers><Grid Background="White"><Ellipse x:Name="Ellipse" Height="20" Width="20" Fill="#FF6666" ><Ellipse.Effect><DropShadowEffect Opacity="1" ShadowDepth="0" Color="#FF6666" BlurRadius="200" Direction="10"></DropShadowEffect></Ellipse.Effect></Ellipse></Grid>
</Window>

三、TextBlock字体呼吸闪烁

代码:

<Window x:Class="WpfApp1.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WpfApp1"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><Grid Background="White"><TextBlock Text="Hello!" FontSize="48" Foreground="#ED4646" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Medium" x:Name="TextBlockRecording"><TextBlock.Triggers><EventTrigger RoutedEvent="FrameworkElement.Loaded"><BeginStoryboard><Storyboard BeginTime="0:0:0" Duration="0:0:4" AutoReverse="True" RepeatBehavior="Forever"><ColorAnimation From="#ED4646" To="#F0F2F7" Duration="0:0:2" RepeatBehavior="Forever" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="TextBlockRecording"></ColorAnimation></Storyboard></BeginStoryboard></EventTrigger></TextBlock.Triggers></TextBlock></Grid>
</Window>

四、报警灯闪烁效果:

<Window x:Class="WpfApp6.Window2"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WpfApp6"mc:Ignorable="d"Title="Window2" Height="450" Width="800"><Window.Resources><Storyboard x:Key="sb" RepeatBehavior="Forever"><ColorAnimationUsingKeyFrames Storyboard.TargetName="light" Storyboard.TargetProperty="Background.(Color)"><DiscreteColorKeyFrame Value="Orange" KeyTime="0:0:0.5"/><DiscreteColorKeyFrame Value="Red" KeyTime="0:0:1"/></ColorAnimationUsingKeyFrames></Storyboard></Window.Resources><Window.Triggers><EventTrigger RoutedEvent="Button.Click" SourceName="button"><BeginStoryboard Storyboard="{StaticResource sb}"/></EventTrigger></Window.Triggers><Grid><Button x:Name="button" Width="100" Height="30" Margin="0 150 0 0"/><Border x:Name="light" Height="60" Width="60" CornerRadius="30" Background="Red" RenderTransformOrigin="0.5,0.5"/></Grid>
</Window>

Storyboard类属性介绍:
AccelerationRatio :获取或设置一个值,该值指定在将时间消逝从零加速到其最大速率的过程中所占用时间线的 Duration 的百分比。 (继承自 Timeline)
AutoReverse :获取或设置一个值,该值指示时间线在完成向前迭代后是否按相反的顺序播放。 (继承自 Timeline)
BeginTime :获取或设置此 Timeline 应开始的时间。 (继承自 Timeline)
CanFreeze :获取一个值,该值指示是否可将对象变为不可修改。 (继承自 Freezable)
Children :获取或设置 TimelineGroup 的直接子 Timeline 对象的集合。 (继承自 TimelineGroup)
DecelerationRatio :获取或设置一个值,该值指定在将时间消逝从其最大速率减速到零的过程中所占用时间线的 Duration 的百分比。 (继承自 Timeline)
DependencyObjectType :获取对此实例的 CLR 类型进行包装的 DependencyObjectType。 (继承自 DependencyObject)
Dispatcher :获取与此 Dispatcher 关联的 DispatcherObject。 (继承自 DispatcherObject)
Duration :获取或设置此时间线播放的时间长度,而不是计数重复。 (继承自 Timeline)
FillBehavior :获取或设置一个值,该值指定 Timeline 在到达其有效期末尾后的行为。 (继承自 Timeline)
HasAnimatedProperties :获取一个值,该值指示一个或多个 AnimationClock 对象是否与此对象的任何依赖项属性相关联。 (继承自 Animatable)
IsFrozen :获取一个值,该值指示对象当前是否可修改。 (继承自 Freezable)
IsSealed :获取一个值,该值指示此实例当前是否为密封的(只读)。 (继承自 DependencyObject)
Name :获取或设置此 Timeline 的名称。 (继承自 Timeline)
RepeatBehavior :获取或设置此时间线的重复行为。 (继承自 Timeline)
SlipBehavior :获取或设置一个值,该值指定在其中一个或多个 Timeline 子级滑动时此时间线的行为方式。 (继承自 ParallelTimeline)
SpeedRatio :获取或设置此 Timeline 的时间相对于其父级的前进速率。 (继承自 Timeline)

WPF 动画闪烁效果相关推荐

  1. WF4.0实战(六):控制WPF动画

    这个例子改造了王晓冬老师的:用WF流程控制WPF动画. 本文用一个小例子演示了在WF中定义两个操作步骤,用来控制WPF页面元素的动画.王冬老师当时使用的是WF3.0,现在我改成WF4.0. 先看效果: ...

  2. WPF 动画显示控件

    原文:WPF 动画显示控件 当我们要显示一个控件的时候,不仅仅要显示这个控件,还要有动画的效果. 主要用到了DoubleAnimation类. public static void ShowAnima ...

  3. silverlight,WPF动画终极攻略之白云飘,坐车去旅游篇(Blend 4开发)

    原文:silverlight,WPF动画终极攻略之白云飘,坐车去旅游篇(Blend 4开发) 这章有点长,所以我分成了两章.这一章主要是准备工作,差不多算美工篇吧,这章基本不会介绍多少动画效果,主要讲 ...

  4. WPF动画之后属性值无法改变

    WPF动画之后属性值无法改变 原文:WPF动画之后属性值无法改变 前一段时间使用WPF写2048游戏的时候,遇到下面的情形:使用按键对色块进行移动时,触发位置左边X和Y属性的DoubleAnimati ...

  5. C# WPF动画——小游戏

    效果: 实现思路 学了WPF动画,一时兴起写了个小游戏哈哈哈哈哈,被女朋友抢去玩了,代码就不贴了,就写一下思路吧. 1.在XAML上,把按键的形状做成一个米老鼠头的形状,并给这个按键一个RenderT ...

  6. silverlight,WPF动画终极攻略之番外 3D切换导航篇(Blend 4开发)

    silverlight,WPF动画终极攻略之番外 3D切换导航篇(Blend 4开发) 原文:silverlight,WPF动画终极攻略之番外 3D切换导航篇(Blend 4开发) 这篇介绍的是3D导 ...

  7. 【WPF学习笔记】[转]周银辉之WPF中的动画 晓风影天之wpf动画——new PropertyPath属性链...

    (一)WPF中的动画 动画无疑是WPF中最吸引人的特色之一,其可以像Flash一样平滑地播放并与程序逻辑进行很好的交互.这里我们讨论一下故事板. 在WPF中我们采用Storyboard(故事板)的方式 ...

  8. silverlight,WPF动画终极攻略之会飞的小鸟篇(Blend 4开发)

    原文: silverlight,WPF动画终极攻略之会飞的小鸟篇(Blend 4开发) 本教程基本涵盖了WPF和silverlight中的各种动画.先上张效果图. 声明下,这个做的不是让大家照搬的,只 ...

  9. C# WPF动画,时钟程序源码分享,闹钟程序源码分享

    钟表界面右击设置闹钟 源码奉上请大佬点评. 注释齐全:不做流氓. 钟表界面xaml代码 <Window x:Class="WPF动画.MainWindow"xmlns=&qu ...

最新文章

  1. 收藏这10个办公神器,让你的职场办公更高效!
  2. 机器学习需要理解的五个基本概念
  3. 优质网站策划从四个方面进行判断
  4. 小米路由器mini改打印服务器_如何把家里的闲置路由器用起来
  5. Ubuntu 12.04 x64 下安装 GStreamer+FFmpeg+Opencv
  6. 2、根据@FeignClient生成代理类
  7. Django 之 Session的简单使用
  8. STM32精英版(正点原子STM32F103ZET6开发板)学习篇1——新建库函数模版
  9. 火狐firefox插件plugin:
  10. php网页微信登录验证失败,微信开发Token验证失败解决方法
  11. CPP使用命令行解压7z文件
  12. 这篇文章感触很深,就作为第一篇吧
  13. 会泡妞的程序员都是怎么撩妹子的?
  14. 「CF1463A」暗黑地牢
  15. PIE-Engine APP:广东省生态遥感指数研究
  16. matlab solve 解的范围,matlab怎么解方程,如何规定解的范围?
  17. 10w 行级别Excel数据量导入优化记录
  18. java如何mock
  19. 航班编程代码c语言,c语言编写航班查询代码.doc
  20. 疫情导致招聘平台Xing的母公司New Work SE裁员

热门文章

  1. 游戏数据分析用到的模型(二)留存率预估
  2. Win10显示器驱动程序无法启动
  3. java写excel_java写excel文件工具
  4. linux可变剪切分析,SUPPA2进行可变剪切定量
  5. .net 汉字转拼音 - 输入汉字获取其拼音
  6. 盗图+php,PHP小偷程序的设计与实现方法详解
  7. 微信发送视频不被压缩的方法
  8. Win10+RTX3060配置CUDA等深度学习环境
  9. 计算机更新并关机能关闭吗,win10关机不想更新并关机而是直接关机步骤设置
  10. 徐松亮常用开发软件与网站