一、样式1
1、效果预览
2、新建自定义控件
<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>
二、样式2
1、效果预览
2、新建自定义控件
<UserControl x:Class="Akeem.AkeemLoading" 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" /> </UserControl.Resources> <Grid Background="Transparent" Name="LayoutRoot"> <Canvas HorizontalAlignment="Center" Height="120" Width="150" RenderTransformOrigin="0,0" VerticalAlignment="Center" > <Canvas.Triggers> <EventTrigger RoutedEvent="FrameworkElement.Loaded"> <BeginStoryboard> <BeginStoryboard.Storyboard> <Storyboard> <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" BeginTime="0:0:0" Storyboard.TargetName="scale1" Storyboard.TargetProperty="(ScaleTransform.ScaleY)" Duration="0:0:1"> <LinearDoubleKeyFrame Value="1" KeyTime="0%" /> <LinearDoubleKeyFrame Value="0.3" KeyTime="50%" /> <LinearDoubleKeyFrame Value="1" KeyTime="100%" /> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" BeginTime="0:0:0.1" Storyboard.TargetName="scale2" Storyboard.TargetProperty="(ScaleTransform.ScaleY)" Duration="0:0:1"> <LinearDoubleKeyFrame Value="1" KeyTime="0%" /> <LinearDoubleKeyFrame Value="0.3" KeyTime="50%" /> <LinearDoubleKeyFrame Value="1" KeyTime="100%" /> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" BeginTime="0:0:0.2" Storyboard.TargetName="scale3" Storyboard.TargetProperty="(ScaleTransform.ScaleY)" Duration="0:0:1"> <LinearDoubleKeyFrame Value="1" KeyTime="0%" /> <LinearDoubleKeyFrame Value="0.3" KeyTime="50%" /> <LinearDoubleKeyFrame Value="1" KeyTime="100%" /> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" BeginTime="0:0:0.3" Storyboard.TargetName="scale4" Storyboard.TargetProperty="(ScaleTransform.ScaleY)" Duration="0:0:1"> <LinearDoubleKeyFrame Value="1" KeyTime="0%" /> <LinearDoubleKeyFrame Value="0.3" KeyTime="50%" /> <LinearDoubleKeyFrame Value="1" KeyTime="100%" /> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" BeginTime="0:0:0.2" Storyboard.TargetName="scale5" Storyboard.TargetProperty="(ScaleTransform.ScaleY)" Duration="0:0:1"> <LinearDoubleKeyFrame Value="1" KeyTime="0%" /> <LinearDoubleKeyFrame Value="0.3" KeyTime="50%" /> <LinearDoubleKeyFrame Value="1" KeyTime="100%" /> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" BeginTime="0:0:0.1" Storyboard.TargetName="scale6" Storyboard.TargetProperty="(ScaleTransform.ScaleY)" Duration="0:0:1"> <LinearDoubleKeyFrame Value="1" KeyTime="0%" /> <LinearDoubleKeyFrame Value="0.3" KeyTime="50%" /> <LinearDoubleKeyFrame Value="1" KeyTime="100%" /> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" BeginTime="0:0:0.0" Storyboard.TargetName="scale7" Storyboard.TargetProperty="(ScaleTransform.ScaleY)" Duration="0:0:1"> <LinearDoubleKeyFrame Value="1" KeyTime="0%" /> <LinearDoubleKeyFrame Value="0.3" KeyTime="50%" /> <LinearDoubleKeyFrame Value="1" KeyTime="100%" /> </DoubleAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard.Storyboard> </BeginStoryboard> </EventTrigger> </Canvas.Triggers> <StackPanel Orientation="Horizontal" > <StackPanel.Resources> <Style TargetType="{x:Type Rectangle}"> <Setter Property="Height" Value="120"/> <Setter Property="Width" Value="10"/> <Setter Property="Margin" Value="5,0"/> <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/> </Style> </StackPanel.Resources> <Rectangle Fill="{StaticResource CirclesColor}" > <Rectangle.RenderTransform> <ScaleTransform x:Name="scale1" ScaleY="1"/> </Rectangle.RenderTransform> </Rectangle> <Rectangle Fill="{StaticResource CirclesColor}"> <Rectangle.RenderTransform> <ScaleTransform x:Name="scale2" ScaleY="1"/> </Rectangle.RenderTransform> </Rectangle> <Rectangle Fill="{StaticResource CirclesColor}"> <Rectangle.RenderTransform> <ScaleTransform x:Name="scale3" ScaleY="1"/> </Rectangle.RenderTransform> </Rectangle> <Rectangle Fill="{StaticResource CirclesColor}"> <Rectangle.RenderTransform> <ScaleTransform x:Name="scale4" ScaleY="1"/> </Rectangle.RenderTransform> </Rectangle> <Rectangle Fill="{StaticResource CirclesColor}"> <Rectangle.RenderTransform> <ScaleTransform x:Name="scale5" ScaleY="1"/> </Rectangle.RenderTransform> </Rectangle> <Rectangle Fill="{StaticResource CirclesColor}"> <Rectangle.RenderTransform> <ScaleTransform x:Name="scale6" ScaleY="1"/> </Rectangle.RenderTransform> </Rectangle> <Rectangle Fill="{StaticResource CirclesColor}"> <Rectangle.RenderTransform> <ScaleTransform x:Name="scale7" ScaleY="1"/> </Rectangle.RenderTransform> </Rectangle> </StackPanel> </Canvas> </Grid> </UserControl>
3、用法
<ex:AkeemLoding></ex:AkeemLoding>