WPF制作一个模仿Silverlight页面还有win8系统的Loading动画效果,其实就用到WPF的ellipse即可,如果想要简单或者更好的效果的话还是要用Blend去做哈。
xaml代码:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Loading动画.Window1" x:Name="Window" Title="Window1" Width="640" Height="480"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Window.Resources>
<Storyboard x:Key="Storyboard1">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" RepeatBehavior="Forever" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="1" />
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse1">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.6000000" Value="1" />
<SplineDoubleKeyFrame KeyTime="00:00:01.1000000" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse2">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.7000000" Value="1" />
<SplineDoubleKeyFrame KeyTime="00:00:01.2000000" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse3">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.8000000" Value="1" />
<SplineDoubleKeyFrame KeyTime="00:00:01.3000000" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse4">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.9000000" Value="1" />
<SplineDoubleKeyFrame KeyTime="00:00:01.4000000" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse5">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.6000000" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="1" />
<SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse6">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.7000000" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:01.1000000" Value="1" />
<SplineDoubleKeyFrame KeyTime="00:00:01.6000000" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse7">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.8000000" Value="0" />