wpf Loading动画 AkeemLoading

1、效果预览

wpf Loading动画 AkeemLoading

1、新建自定义控件

<UserControl x:Class="Akeem.AkeemLoding"
             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" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <SolidColorBrush Color="#FF007BE5" x:Key="CirclesColor" />
        <!--<SolidColorBrush Color="Black" x:Key="BackgroundColor" Opacity=".20" />-->
    </UserControl.Resources>
    <Grid Background="Transparent" Name="LayoutRoot">
        <Grid.RenderTransform>
            <ScaleTransform x:Name="SpinnerScale" ScaleX="1.0" ScaleY="1.0" />
        </Grid.RenderTransform>
        <Canvas Height="120" HorizontalAlignment="Center" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Center" Width="120">
            <Canvas.Triggers>
                <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                    <BeginStoryboard>
                        <BeginStoryboard.Storyboard>
                            <Storyboard>
                                <DoubleAnimation RepeatBehavior="Forever" AccelerationRatio="0.1" SpeedRatio="4" Duration="0:0:0:04" From="0" Storyboard.TargetName="Ellipse1" Storyboard.TargetProperty="(RotateTransform.Angle)" To="360"  />
                                <DoubleAnimation RepeatBehavior="Forever" AccelerationRatio="0.2" SpeedRatio="4" Duration="0:0:0:04" From="0" Storyboard.TargetName="Ellipse2" Storyboard.TargetProperty="(RotateTransform.Angle)" To="360"  />
                                <DoubleAnimation RepeatBehavior="Forever" AccelerationRatio="0.3" SpeedRatio="4" Duration="0:0:0:04" From="0" Storyboard.TargetName="Ellipse3" Storyboard.TargetProperty="(RotateTransform.Angle)" To="360"  />
                                <DoubleAnimation RepeatBehavior="Forever" AccelerationRatio="0.4" SpeedRatio="4" Duration="0:0:0:04" From="0" Storyboard.TargetName="Ellipse4" Storyboard.TargetProperty="(RotateTransform.Angle)" To="360"  />
                                <DoubleAnimation RepeatBehavior="Forever" AccelerationRatio="0.5" SpeedRatio="4" Duration="0:0:0:04" From="0" Storyboard.TargetName="Ellipse5" Storyboard.TargetProperty="(RotateTransform.Angle)" To="360"  />
                                <DoubleAnimation RepeatBehavior="Forever" AccelerationRatio="0.6" SpeedRatio="4" Duration="0:0:0:04" From="0" Storyboard.TargetName="Ellipse6" Storyboard.TargetProperty="(RotateTransform.Angle)" To="360"  />
                                <DoubleAnimation RepeatBehavior="Forever" AccelerationRatio="0.7" SpeedRatio="4" Duration="0:0:0:04" From="0" Storyboard.TargetName="Ellipse7" Storyboard.TargetProperty="(RotateTransform.Angle)" To="360"  />
                                <DoubleAnimation RepeatBehavior="Forever" AccelerationRatio="0.8" SpeedRatio="4" Duration="0:0:0:04" From="0" Storyboard.TargetName="Ellipse8" Storyboard.TargetProperty="(RotateTransform.Angle)" To="360"  />
                                <DoubleAnimation RepeatBehavior="Forever" AccelerationRatio="0.9" SpeedRatio="4" Duration="0:0:0:04" From="0" Storyboard.TargetName="Ellipse9" Storyboard.TargetProperty="(RotateTransform.Angle)" To="360"  />
                                <DoubleAnimation RepeatBehavior="Forever" AccelerationRatio="1" SpeedRatio="4" Duration="0:0:0:04" From="0" Storyboard.TargetName="Ellipse10" Storyboard.TargetProperty="(RotateTransform.Angle)" To="360" />
                             </Storyboard>
                        </BeginStoryboard.Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Canvas.Triggers>
            <Ellipse RenderTransformOrigin="0.455,2.727" 
                     Canvas.Left="50" 
                     Fill="{StaticResource CirclesColor}" 
                     Height="22" 
                     Opacity="1" 
                     Stretch="Fill" 
                     Width="22" Canvas.Top="0" >
                <Ellipse.RenderTransform>
                    <RotateTransform x:Name="Ellipse1" Angle="0" />
                </Ellipse.RenderTransform>
            </Ellipse>
            <Ellipse RenderTransformOrigin="0.455,2.727" 
                     Canvas.Left="50" 
                     Fill="{StaticResource CirclesColor}" 
                     Height="22" 
                     Opacity="1" 
                     Stretch="Fill" 
                     Width="22" Canvas.Top="0" >
                <Ellipse.RenderTransform>
                    <RotateTransform x:Name="Ellipse2" Angle="0" />
                </Ellipse.RenderTransform>
            </Ellipse>
            <Ellipse RenderTransformOrigin="0.455,2.727" 
                     Canvas.Left="50" 
                     Fill="{StaticResource CirclesColor}" 
                     Height="22" 
                     Opacity="1" 
                     Stretch="Fill" 
                     Width="22" Canvas.Top="0" >
                <Ellipse.RenderTransform>
                    <RotateTransform x:Name="Ellipse3" Angle="0" />
                </Ellipse.RenderTransform>
            </Ellipse>
            <Ellipse RenderTransformOrigin="0.455,2.727" 
                     Canvas.Left="50" 
                     Fill="{StaticResource CirclesColor}" 
                     Height="22" 
                     Opacity="1" 
                     Stretch="Fill" 
                     Width="22" Canvas.Top="0" >
                <Ellipse.RenderTransform>
                    <RotateTransform x:Name="Ellipse4" Angle="0" />
                </Ellipse.RenderTransform>
            </Ellipse>
            <Ellipse RenderTransformOrigin="0.455,2.727" 
                     Canvas.Left="50" 
                     Fill="{StaticResource CirclesColor}" 
                     Height="22" 
                     Opacity="1" 
                     Stretch="Fill" 
                     Width="22" Canvas.Top="0" >
                <Ellipse.RenderTransform>
                    <RotateTransform x:Name="Ellipse5" Angle="0" />
                </Ellipse.RenderTransform>
            </Ellipse>
            <Ellipse RenderTransformOrigin="0.455,2.727" 
                     Canvas.Left="50" 
                     Fill="{StaticResource CirclesColor}" 
                     Height="22" 
                     Opacity="1" 
                     Stretch="Fill" 
                     Width="22" Canvas.Top="0" >
                <Ellipse.RenderTransform>
                    <RotateTransform x:Name="Ellipse6" Angle="0" />
                </Ellipse.RenderTransform>
            </Ellipse>
            <Ellipse RenderTransformOrigin="0.455,2.727" 
                     Canvas.Left="50" 
                     Fill="{StaticResource CirclesColor}" 
                     Height="22" 
                     Opacity="1" 
                     Stretch="Fill" 
                     Width="22" Canvas.Top="0" >
                <Ellipse.RenderTransform>
                    <RotateTransform x:Name="Ellipse7" Angle="0" />
                </Ellipse.RenderTransform>
            </Ellipse>
            <Ellipse RenderTransformOrigin="0.455,2.727" 
                     Canvas.Left="50" 
                     Fill="{StaticResource CirclesColor}" 
                     Height="22" 
                     Opacity="1" 
                     Stretch="Fill" 
                     Width="22" Canvas.Top="0" >
                <Ellipse.RenderTransform>
                    <RotateTransform x:Name="Ellipse8" Angle="0" />
                </Ellipse.RenderTransform>
            </Ellipse>
            <Ellipse RenderTransformOrigin="0.455,2.727" 
                     Canvas.Left="50" 
                     Fill="{StaticResource CirclesColor}" 
                     Height="22" 
                     Opacity="1" 
                     Stretch="Fill" 
                     Width="22" Canvas.Top="0" >
                <Ellipse.RenderTransform>
                    <RotateTransform x:Name="Ellipse9" Angle="0" />
                </Ellipse.RenderTransform>
            </Ellipse>
            <Ellipse RenderTransformOrigin="0.455,2.727" 
                     Canvas.Left="50" 
                     Fill="{StaticResource CirclesColor}" 
                     Height="22" 
                     Opacity="1" 
                     Stretch="Fill" 
                     Width="22" Canvas.Top="0" >
                <Ellipse.RenderTransform>
                    <RotateTransform x:Name="Ellipse10" Angle="0" />
                </Ellipse.RenderTransform>
            </Ellipse>
            
        </Canvas>
        <TextBlock Text="Loading..." x:Name="text_Loading" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14" Foreground="#FFE3953D" FontWeight="Bold" />
    </Grid>
</UserControl>

 3、用法

<ex:AkeemLoding></ex:AkeemLoding>

wpf Loading动画 AkeemLoading

上一篇:配置Windows Server 2008路由器


下一篇:APP自动化测试各项指标分析