Анимация в XAML
Для страждущих.
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WpfEx.MainWindow"
x:Name="Window"
Title="MainWindow"
Width="640" Height="480">
<Window.Resources>
<Storyboard x:Key="OnLoadedLeft">
<DoubleAnimationUsingKeyFrames AutoReverse="True"
RepeatBehavior="Forever"
BeginTime="00:00:00"
Storyboard.TargetName="ellipse"
Storyboard.TargetProperty="(Canvas.Left)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
<SplineDoubleKeyFrame KeyTime="00:00:03" Value="400"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="OnLoadedTop">
<DoubleAnimationUsingKeyFrames AutoReverse="True"
RepeatBehavior="Forever"
BeginTime="00:00:00"
Storyboard.TargetName="ellipse"
Storyboard.TargetProperty="(Canvas.Top)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
<SplineDoubleKeyFrame KeyTime="00:00:03.5" Value="300"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Window.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource OnLoadedLeft}"/>
</EventTrigger>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource OnLoadedTop}"/>
</EventTrigger>
</Window.Triggers>
<Canvas>
<Ellipse x:Name="ellipse"
Fill="#FF1A19E8"
Stroke="Black"
Width="50"
Height="50"
Canvas.Left="0"
Canvas.Top="0"
StrokeThickness="0"/>
</Canvas>
</Window>


0 коммент.:
Отправить комментарий