MainWindow.xamlの全コード
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="370" Width="450">
<Canvas Width="400" Height="300" Background="#FFABDBAB">
<!-- 背景色の設定 -->
<Canvas.Triggers>
<EventTrigger RoutedEvent="Canvas.Loaded">
<!-- ボールのアニメーション -->
<BeginStoryboard x:Name="myBoard">
<Storyboard>
<!-- 縦方向の移動 -->
<DoubleAnimation From="-10" To="290" Duration="0:0:0.7" Storyboard.TargetName="myEllipse" Storyboard.TargetProperty="(Canvas.Top)" AutoReverse="True" RepeatBehavior="Forever" />
<!-- 横方向の移動 -->
<DoubleAnimation From="-10" To="390" Duration="0:0:0.5" Storyboard.TargetName="myEllipse" Storyboard.TargetProperty="(Canvas.Left)" AutoReverse="True" RepeatBehavior="Forever" />
<!-- 横方向の移動R-->
<DoubleAnimation From="-20" To="380" Duration="0:0:2" Storyboard.TargetName="Ellipse1" Storyboard.TargetProperty="(Canvas.Left)" AutoReverse="True" RepeatBehavior="Forever" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Canvas.Triggers>
<!-- 赤いボールの記述 -->
<Ellipse x:Name="myEllipse" Fill="Red" Width="20" Height="20" Canvas.Left="-10" Canvas.Top="-10" />
<!-- 青いボールの記述 -->
<Ellipse Canvas.Left="76" Canvas.Top="179" Height="40" Name="Ellipse1" Width="40">
<Ellipse.Fill>
<RadialGradientBrush>
<GradientStop Color="#FFC341DB" Offset="0.3" />
<GradientStop Color="#FF1E8CEB" Offset="1" />
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
</Canvas>
</Window>