WPF: Animations in XAML and code-behind

WPF makes it very easy to define animations, by using timelines, storyboards and dependency properties. Animations can be defined and triggered in XAML, or they can be defined in XAML and triggered in C#, or they can even be fully defined and triggered in C#.
I just published a tutorial explaining the basic concepts of animations in WPF, with examples and a demo (runs in IE, with WPF September CTP (RC1) installed). The article shows 3 different ways to animate an object. Of course, you can also download the source code.
<Page.Triggers>
  <EventTrigger RoutedEvent="TextBlock.MouseDown"
                SourceName="lblHello">
    <EventTrigger.Actions>
      <BeginStoryboard>
        <Storyboard>
          <DoubleAnimation
            Storyboard.TargetName="lblHello"
            Storyboard.TargetProperty="(TextBlock.RenderTransform).(RotateTransform.Angle)"
            From="0"
            To="360"
            Duration="0:0:0.5"
            RepeatBehavior="4x" />
        </Storyboard>
      </BeginStoryboard>
    </EventTrigger.Actions>
  </EventTrigger>
</Page.Triggers>
WPF animation in XAML
Print | posted on Saturday, October 28, 2006 8:39 PM

Feedback

# re: WPF: Animations in XAML and code-behind

left by Metropolis12 at 3/10/2007 10:53 PM Gravatar
I can't get a video to loop. Do I use repeatBehavior for this?
Title  
Name
Email (never displayed)
Url
Comments   
Please add 7 and 3 and type the answer here: