Ball moves in a constant speed : Ball Animation « Windows Presentation Foundation « C# / CSharp Tutorial






<Window x:Class="SplineKeyFrameAnimation"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="Spline Key Frame Animation" Height="250" Width="400">
  <Canvas Margin="5">
    <Ellipse Name="ball1" Canvas.Left="10" Canvas.Top="50" Width="20" Height="20">
      <Ellipse.Fill>
        <RadialGradientBrush>
          <GradientStop Color="Gold" Offset="0" />
          <GradientStop Color="DarkGoldenrod" Offset="1" />
        </RadialGradientBrush>
      </Ellipse.Fill>
    </Ellipse>
    <Canvas.Triggers>
      <EventTrigger RoutedEvent="StackPanel.Loaded">
        <EventTrigger.Actions>
          <BeginStoryboard>
            <Storyboard>
              <DoubleAnimation
                Storyboard.TargetName="ball1"
                Storyboard.TargetProperty="(Canvas.Left)" To="310"
                Duration="0:0:10" RepeatBehavior="Forever" />
            </Storyboard>
          </BeginStoryboard>
        </EventTrigger.Actions>
      </EventTrigger>
    </Canvas.Triggers>
  </Canvas>
</Window>
WPF Ball Moves In A Constant Speed








24.113.Ball Animation
24.113.1.Bouncing BallBouncing Ball
24.113.2.Bouncing Ball with ParallelTimelineBouncing Ball with ParallelTimeline
24.113.3.Bouncing Ball with DoubleAnimationBouncing Ball with DoubleAnimation
24.113.4.Ball moves in a constant speedBall moves in a constant speed
24.113.5.Rolling Ball AnimationRolling Ball Animation
24.113.6.Animate Ball HeightAnimate Ball Height