原文:WPF 加载等待动画

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_29844879/article/details/80216587

直接上代码:

xmal:

  1. <Controls:MetroWindow x:Class="MyControlLibrarys.LoadDialog"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6. xmlns:local="clr-namespace:MyControlLibrarys"
  7. Title="正在加载" WindowStyle="None" Height="180" Width="430" ShowMaxRestoreButton="False" ShowMinButton="False" ShowCloseButton="False"
  8. WindowStartupLocation="CenterScreen" Opacity="1">
  9. <Grid>
  10. <Grid.ColumnDefinitions>
  11. <ColumnDefinition Width="*"/>
  12. <ColumnDefinition Width="4*"/>
  13. </Grid.ColumnDefinitions>
  14. <Label Height="36" Grid.Column="1" HorizontalAlignment="Left" Margin="20 0" Name="message" VerticalAlignment="Center" FontSize="20" />
  15. <Grid Width="35" Height="35">
  16. <Grid.Resources>
  17. <DrawingBrush x:Key="brush" Stretch="None" AlignmentX="Center" AlignmentY="Top">
  18. <DrawingBrush.Drawing>
  19. <GeometryDrawing Brush="Black">
  20. <GeometryDrawing.Geometry>
  21. <EllipseGeometry RadiusX="2" RadiusY="5"/>
  22. </GeometryDrawing.Geometry>
  23. </GeometryDrawing>
  24. </DrawingBrush.Drawing>
  25. </DrawingBrush>
  26. </Grid.Resources>
  27. <Rectangle x:Name="r01" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
  28. <Rectangle.RenderTransform>
  29. <RotateTransform Angle="0"/>
  30. </Rectangle.RenderTransform>
  31. </Rectangle>
  32. <Rectangle x:Name="r02" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
  33. <Rectangle.RenderTransform>
  34. <RotateTransform Angle="30"/>
  35. </Rectangle.RenderTransform>
  36. </Rectangle>
  37. <Rectangle x:Name="r03" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
  38. <Rectangle.RenderTransform>
  39. <RotateTransform Angle="60"/>
  40. </Rectangle.RenderTransform>
  41. </Rectangle>
  42. <Rectangle x:Name="r04" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
  43. <Rectangle.RenderTransform>
  44. <RotateTransform Angle="90"/>
  45. </Rectangle.RenderTransform>
  46. </Rectangle>
  47. <Rectangle x:Name="r05" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
  48. <Rectangle.RenderTransform>
  49. <RotateTransform Angle="120"/>
  50. </Rectangle.RenderTransform>
  51. </Rectangle>
  52. <Rectangle x:Name="r06" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
  53. <Rectangle.RenderTransform>
  54. <RotateTransform Angle="150"/>
  55. </Rectangle.RenderTransform>
  56. </Rectangle>
  57. <Rectangle x:Name="r07" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
  58. <Rectangle.RenderTransform>
  59. <RotateTransform Angle="180"/>
  60. </Rectangle.RenderTransform>
  61. </Rectangle>
  62. <Rectangle x:Name="r08" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
  63. <Rectangle.RenderTransform>
  64. <RotateTransform Angle="210"/>
  65. </Rectangle.RenderTransform>
  66. </Rectangle>
  67. <Rectangle x:Name="r09" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
  68. <Rectangle.RenderTransform>
  69. <RotateTransform Angle="240"/>
  70. </Rectangle.RenderTransform>
  71. </Rectangle>
  72. <Rectangle x:Name="r10" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
  73. <Rectangle.RenderTransform>
  74. <RotateTransform Angle="270"/>
  75. </Rectangle.RenderTransform>
  76. </Rectangle>
  77. <Rectangle x:Name="r11" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
  78. <Rectangle.RenderTransform>
  79. <RotateTransform Angle="300"/>
  80. </Rectangle.RenderTransform>
  81. </Rectangle>
  82. <Rectangle x:Name="r12" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
  83. <Rectangle.RenderTransform>
  84. <RotateTransform Angle="330"/>
  85. </Rectangle.RenderTransform>
  86. </Rectangle>
  87. <Grid.Triggers>
  88. <EventTrigger RoutedEvent="Grid.Loaded">
  89. <BeginStoryboard>
  90. <Storyboard RepeatBehavior="Forever">
  91. <DoubleAnimation Storyboard.TargetName="r01" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.00000" To="0"/>
  92. <DoubleAnimation Storyboard.TargetName="r02" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.08333" To="0"/>
  93. <DoubleAnimation Storyboard.TargetName="r03" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.16666" To="0"/>
  94. <DoubleAnimation Storyboard.TargetName="r04" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.24999" To="0"/>
  95. <DoubleAnimation Storyboard.TargetName="r05" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.33332" To="0"/>
  96. <DoubleAnimation Storyboard.TargetName="r06" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.41665" To="0"/>
  97. <DoubleAnimation Storyboard.TargetName="r07" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.49998" To="0"/>
  98. <DoubleAnimation Storyboard.TargetName="r08" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.58331" To="0"/>
  99. <DoubleAnimation Storyboard.TargetName="r09" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.66664" To="0"/>
  100. <DoubleAnimation Storyboard.TargetName="r10" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.74997" To="0"/>
  101. <DoubleAnimation Storyboard.TargetName="r11" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.83330" To="0"/>
  102. <DoubleAnimation Storyboard.TargetName="r12" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.91663" To="0"/>
  103. </Storyboard>
  104. </BeginStoryboard>
  105. </EventTrigger>
  106. </Grid.Triggers>
  107. </Grid>
  108. </Grid>
  109. </Controls:MetroWindow>

.cs:

  1. /// <summary>
  2. /// Interaction logic for LoadDialog.xaml
  3. /// </summary>
  4. public partial class LoadDialog : MetroWindow
  5. {
  6. public LoadDialog()
  7. {
  8. InitializeComponent();
  9. //this.Topmost = true; //始终保持最上层
  10. }
  11. public void SetProgressText(string desc)
  12. {
  13. //this.message.Content = desc;
  14. this.Dispatcher.Invoke(new Action(() =>
  15. {
  16. this.message.Content = desc;
  17. }));
  18. }
  19. }

WPF 加载等待动画的更多相关文章

  1. WPF加载等待动画

    原文:WPF加载等待动画 原文地址:https://www.codeproject.com/Articles/57984/WPF-Loading-Wait-Adorner 界面遮罩 <UserC ...

  2. [Swift通天遁地]一、超级工具-(11)使用EZLoadingActivity制作Loading加载等待动画

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  3. vue实现首屏加载等待动画 避免首次加载白屏尴尬

    0 直接上效果图 1背景,用户体验良好一直是个重要的问题. 2怎么加到自己项目里面? 复制css html代码到自己的index.html即可 代码链接 源码地址 Vue学习前端群493671066, ...

  4. IOS开发UI篇之──自定义加载等待框(MBProgressHUD)

    本文转载至 http://blog.csdn.net/xunyn/article/details/8064984   原文地址http://www.189works.com/article-89289 ...

  5. 【Ionic】---$ionicLoading ion-spinner SVG旋转加载的动画图标

    ionic 加载动作 $ionicLoading $ionicLoading 是 ionic 默认的一个加载交互效果.里面的内容也是可以在模板里面修改. 用法 angular.module('Load ...

  6. 页面预加载loading动画,再载入内容

    默认情况下如果网站请求速度慢,所以会有一段时间的空白页面等等,用户体验效果不好,见到很多的页面都有预加载的效果,加载之前先加载一个动画,后台进程继续加载页面内容,当页面内容加载完之后再退出动画显示内容 ...

  7. HTML5+javascript实现图片加载进度动画效果

    在网上找资料的时候,看到网上有图片加载进度的效果,手痒就自己也写了一个. 图片加载完后,隐藏loading效果. 想看加载效果,请ctrel+F5强制刷新或者清理缓存. 效果预览:   0%   // ...

  8. 纯css3 加载loading动画特效

    最近项目中要实现当页面还没有加载完给用户提示正在加载的loading,本来是想做个图片提示的,但是图片如果放大电脑的分辨率就会感觉到很虚,体验效果很不好.于是就采用css3+js实现这个loading ...

  9. C#窗体的加载等待(BackgroundWorker控件)实现

    窗体拉一个Button按钮和一个加载等待显示的label, label默认隐藏,点击按钮时显示这个label,加载完再隐藏 1.工具箱拉BackgroundWorker控件到窗体 2.backgrou ...

随机推荐

  1. Android studio 安装与配置【Android学习入门】

    终于下定决心认真学习Android开发了. 之前在很多平台看到很多大牛们学习Android的经验和心得,纸上得来终觉浅. 这里推荐stormzhang老师总结的Android学习之路. 为了防止电脑卡 ...

  2. adobe air ane 中有的java class 打包 apk 后却没有了报NoClassDefFoundError ,ClassNotFoundException

    apache flex sdk 手机项目 09-18 10:34:55.030: E/AndroidRuntime(19513): FATAL EXCEPTION: main 09-18 10:34: ...

  3. 如何让MVC和多层架构和谐并存(一)

    MVC的架构和多层架构,在ORM框架上是不兼容的.MVC的数据库操作需要通过实体框架Entity Framework,多层的数据库操作需要通过DAL层.我们最近刚完成的项目,实现了MVC和多层的并存, ...

  4. 如何在VMware ubuntu linux虚拟机中安装VMware tools

    VMware Tools可以实现在主机<->虚拟机之间拷贝文字.文件等功能.本文讲述如何在VMware ubuntu linux虚拟机中安装VMware tools. 测试环境: VMwa ...

  5. FTP无法连接可能是安全狗设置的原因

    防火墙已添加某端口,但仍无法连接.可能是安全狗导致的. 如果安装了安全狗,请按照以下步骤设置:

  6. 百度Ueditor 图片上传无反应,显示上传0张,不能点确定

    解决办法: \Data\Ueditor\php\Uploader.class.php 190行左右 /** * 获取文件扩展名 * @return string */ private function ...

  7. Deep Learning Libraries by Language

    Deep Learning Libraries by Language Tweet         Python Theano is a python library for defining and ...

  8. js循环读取json数据,将读取到的数据用js写成表格

    ①js循环读取json数据的方式: var data=[{"uid":"2688","uname":"*江苏省南菁高级中学 022 ...

  9. JS isArray、typeof、instanceof

    Array.isArray() 用来检验是不是数组 var a = [1,2,3] console.log(typeof a); // object console.log(Array.isArray ...

  10. 当Java遇见了Html--Jsp详解篇

    ###一.什么是Jsp jsp是一种基于文本的程序,全名java server page,其特点是html和java程序共存.执行时jsp会被运行容器编译,编译后的jsp跟servlet一样,因此js ...