直接上代码:
Client.Controls.LoginLoading.xaml:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
x:Class="Client.Controls.LoginLoading"
Width="150" Height="150">
<UserControl.Resources>
<LinearGradientBrush x:Key="ForegroundBrush" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="CornflowerBlue" Offset="1"/>
<GradientStop Color="Cyan"/>
</LinearGradientBrush>
<Storyboard x:Name="Big" RepeatBehavior="Forever">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="Bigger">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="360"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Name="Small" RepeatBehavior="Forever">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="Smaller">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:12" Value="360"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</UserControl.Resources>
<i:Interaction.Triggers>
<i:EventTrigger>
<ei:ControlStoryboardAction Storyboard="{StaticResource Big}"/>
<ei:ControlStoryboardAction Storyboard="{StaticResource Small}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<Grid>
<Rectangle Width="150" Height="150" RadiusX="150" RadiusY="150" >
<Rectangle.Fill>
<ImageBrush ImageSource="../Images/Background.png"/>
</Rectangle.Fill>
</Rectangle>
<Grid x:Name="LayoutRoot">
<ed:Arc ArcThickness="13" EndAngle="360" Stretch="None" UseLayoutRounding="False" Fill="{StaticResource ForegroundBrush}"/>
<Ellipse Fill="{StaticResource ForegroundBrush}" Margin="25"/>
<Ellipse Fill="{StaticResource ForegroundBrush}" Margin="70"/>
<Path x:Name="Bigger" Fill="{StaticResource ForegroundBrush}" Margin="0,28,0,0" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Top" Width="16" Height="40" Data="M0,0 C3,7 8,17 8,26 C8,30 3,38 0,40 M0,0 C-3,7 -8,17 -8,26 C-8,30 -3,38 0,40" RenderTransformOrigin="0.5,1.3">
<Path.RenderTransform>
<CompositeTransform/>
</Path.RenderTransform>
</Path>
<Path x:Name="Smaller" Fill="{StaticResource ForegroundBrush}" Margin="0,39,0,0" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Top" Width="11" Height="28" Data="M0,0 C3,7 8,17 8,26 C8,30 3,38 0,40 M0,0 C-3,7 -8,17 -8,26 C-8,30 -3,38 0,40" RenderTransformOrigin="0.5,1.464">
<Path.RenderTransform>
<CompositeTransform/>
</Path.RenderTransform>
</Path>
</Grid>
</Grid>
</UserControl>
引用的页面 *.xaml:
<Canvas x:Name="ContainerCanvas">
</Canvas>
后台代码*.xaml.cs:
LoginLoading loginloading = new LoginLoading();
ContainerCanvas.Children.Add(loginloading);