一直想做个wpf的loading遮罩效果
闲来无事网上看看别人做的 拔下来一个效果 共享给大家 如果有更好的可以告诉我下
先上个效果图
基本效果就是这样 实现起来也是只有xaml的动画
代码如下
<UserControl x:Class="Test.LoadingMask"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
IsHitTestVisible="False"
>
<UserControl.Resources>
<!--block style-->
<Style x:Key="PathStyle" TargetType="Path">
<Setter Property="Fill" Value="#FF0092FF"></Setter>
<Setter Property="Stretch" Value="Fill"></Setter>
<Setter Property="RenderTransformOrigin" Value="0.5,4.3"></Setter>
<Setter Property="VerticalAlignment" Value="Top"></Setter>
<Setter Property="Height" Value="10"></Setter>
</Style>
<!-- A block in the progress ring (why does this trapezoid have a dozen corners?) -->
<Geometry x:Key="Block">
M291.15499,85.897525
C291.15499,85.897525
301.88917,85.87921
301.88917,85.87921
301.88917,85.87921
300.38339,94.355061
300.38339,94.355061
300.38339,94.355061
292.85366,94.355042
292.85366,94.355042
292.85366,94.355042
291.15499,85.897525
291.15499,85.897525
Z
</Geometry>
<!-- Animations for the individual blocks of the progress ring -->
<Storyboard x:Key="ProgressAnimation" RepeatBehavior="Forever">
<ColorAnimationUsingKeyFrames Duration="00:00:03.6" Storyboard.TargetName="block0" Storyboard.TargetProperty="(UIElement.OpacityMask).(SolidColorBrush.Color)">
<LinearColorKeyFrame KeyTime="00:00:00.0" Value="#FF000000"/>
<LinearColorKeyFrame KeyTime="00:00:00.2" Value="#EF000000"/>
<LinearColorKeyFrame KeyTime="00:00:00.4" Value="#E2000000"/>
<LinearColorKeyFrame KeyTime="00:00:00.6" Value="#D3000000"/>
<LinearColorKeyFrame KeyTime="00:00:00.8" Value="#C6000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.0" Value="#B7000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.2" Value="#AA000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.4" Value="#9B000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.6" Value="#8E000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.8" Value="#7F000000"/>
<LinearColorKeyFrame KeyTime="00:00:02.0" Value="#72000000"/>
<LinearColorKeyFrame KeyTime="00:00:02.2" Value="#63000000"/>
<LinearColorKeyFrame KeyTime="00:00:02.4" Value="#56000000"/>
<LinearColorKeyFrame KeyTime="00:00:02.6" Value="#3D000000"/>
<LinearColorKeyFrame KeyTime="00:00:02.8" Value="#26000000"/>
<LinearColorKeyFrame KeyTime="00:00:03.0" Value="#19000000"/>
<LinearColorKeyFrame KeyTime="00:00:03.2" Value="#0C000000"/>
<LinearColorKeyFrame KeyTime="00:00:03.4" Value="#00000000"/>
<LinearColorKeyFrame KeyTime="00:00:03.6" Value="#FF000000"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Duration="00:00:03.6" Storyboard.TargetName="block1" Storyboard.TargetProperty="(UIElement.OpacityMask).(SolidColorBrush.Color)">
<LinearColorKeyFrame KeyTime="00:00:00.0" Value="#00000000"/>
<LinearColorKeyFrame KeyTime="00:00:00.2" Value="#FF000000"/>
<LinearColorKeyFrame KeyTime="00:00:00.4" Value="#EF000000"/>
<LinearColorKeyFrame KeyTime="00:00:00.6" Value="#E2000000"/>
<LinearColorKeyFrame KeyTime="00:00:00.8" Value="#D3000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.0" Value="#C6000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.2" Value="#B7000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.4" Value="#AA000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.6" Value="#9B000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.8" Value="#8E000000"/>
<LinearColorKeyFrame KeyTime="00:00:02.0" Value="#7F000000"/>
<LinearColorKeyFrame KeyTime="00:00:02.2" Value="#72000000"/>
<LinearColorKeyFrame KeyTime="00:00:02.4" Value="#63000000"/>
<LinearColorKeyFrame KeyTime="00:00:02.6" Value="#56000000"/>
<LinearColorKeyFrame KeyTime="00:00:02.8" Value="#3D000000"/>
<LinearColorKeyFrame KeyTime="00:00:03.0" Value="#26000000"/>
<LinearColorKeyFrame KeyTime="00:00:03.2" Value="#19000000"/>
<LinearColorKeyFrame KeyTime="00:00:03.4" Value="#0C000000"/>
<LinearColorKeyFrame KeyTime="00:00:03.6" Value="#00000000"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Duration="00:00:03.6" Storyboard.TargetName="block2" Storyboard.TargetProperty="(UIElement.OpacityMask).(SolidColorBrush.Color)">
<LinearColorKeyFrame KeyTime="00:00:00.0" Value="#0C000000"/>
<LinearColorKeyFrame KeyTime="00:00:00.2" Value="#00000000"/>
<LinearColorKeyFrame KeyTime="00:00:00.4" Value="#FF000000"/>
<LinearColorKeyFrame KeyTime="00:00:00.6" Value="#EF000000"/>
<LinearColorKeyFrame KeyTime="00:00:00.8" Value="#E2000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.0" Value="#D3000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.2" Value="#C6000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.4" Value="#B7000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.6" Value="#AA000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.8" Value="#9B000000"/>
<LinearColorKeyFrame KeyTime="00:00:02.0" Value="#91000000"/>
<LinearColorKeyFrame KeyTime="00:00:02.2" Value="#7F000000"/>
<LinearColorKeyFrame KeyTime="00:00:02.4" Value="#72000000"/>
<LinearColorKeyFrame KeyTime="00:00:02.6" Value="#63000000"/>
<LinearColorKeyFrame KeyTime="00:00:02.8" Value="#56000000"/>
<LinearColorKeyFrame KeyTime="00:00:03.0" Value="#3D000000"/>
<LinearColorKeyFrame KeyTime="00:00:03.2" Value="#26000000"/>
<LinearColorKeyFrame KeyTime="00:00:03.4" Value="#19000000"/>
<LinearColorKeyFrame KeyTime="00:00:03.6" Value="#0C000000"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Duration="00:00:03.6" Storyboard.TargetName="block3" Storyboard.TargetProperty="(UIElement.OpacityMask).(SolidColorBrush.Color)">
<LinearColorKeyFrame KeyTime="00:00:00.0" Value="#19000000"/>
<LinearColorKeyFrame KeyTime="00:00:00.2" Value="#0C000000"/>
<LinearColorKeyFrame KeyTime="00:00:00.4" Value="#00000000"/>
<LinearColorKeyFrame KeyTime="00:00:00.6" Value="#FF000000"/>
<LinearColorKeyFrame KeyTime="00:00:00.8" Value="#EF000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.0" Value="#E2000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.2" Value="#D3000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.4" Value="#C6000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.6" Value="#B7000000"/>
<LinearColorKeyFrame KeyTime="00:00:01.8" Value="#AA000000"/>
<LinearColorKeyFrame KeyTime="00:00:02.0" Value="#9B000000"/>
<LinearColorKeyFrame KeyTime="00:00:02.2" Value="#91000000"/>