Sunday, August 14, 2005
Using Animation (Emphasis on splines)
Animations are enumerated by type: double, point, color, etc...
Animations support simple (To, From), complex (key frame values: value1, value2, value3...), and user-defined (explicit path) scenarios...
         Animations named for simple are: <type>Animation
         Animations named for complex are: <type>AnimationUsingKeyFrames
         Animations names for user-defined are <type>AnimationUsingPath
Inside complex animations, there are 3 different progression techniques:
         discrete (jumps to values with no in-between values)
         linear (line progression from value to value)
         spline (spline curve progression with 2 control points)
User-defined animations are specified using a Path geometry
 
Here is a sample using DoubleAnimationUsingKeyFrames:
<Style x:Key="Style1">
   <Setter Property="Button.Background">
      <Setter.Value>
         <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
            <LinearGradientBrush.GradientStops>
               <GradientStop Color="Pink" Offset="0" />
               <GradientStop Color="Red" Offset="1" />
            </LinearGradientBrush.GradientStops>
         </LinearGradientBrush>
      </Setter.Value>
   </Setter>
   <Setter Property="Control.Template">
      <Setter.Value>
         <ControlTemplate>
            <Grid x:Name="grid">
               <Grid.RenderTransform>
                  <TranslateTransform X="0" Y="0" />
               </Grid.RenderTransform>
               <Rectangle Fill="{TemplateBinding Property=Background}" RadiusX="5" RadiusY="5" Margin="2" />
            </Grid>
            <ControlTemplate.Triggers>
               <EventTrigger RoutedEvent="Mouse.MouseEnter">
                  <EventTrigger.Actions>
                     <BeginAction TargetName="MouseEnterTimeline2" />
                  </EventTrigger.Actions>
               </EventTrigger>
            </ControlTemplate.Triggers>
            <ControlTemplate.Storyboards>
               <ParallelTimeline Name="MouseEnterTimeline" BeginTime="*null" Duration="Forever">
                  <SetterTimeline TargetName="grid" Path="(Grid.RenderTransform).(TranslateTransform.X)" FillBehavior="HoldEnd">
                     <DoubleAnimationUsingKeyFrames Duration="0:0:1.3" FillBehavior="HoldEnd">
                        <DoubleAnimationUsingKeyFrames.KeyFrames>
                           <SplineDoubleKeyFrame Value="10" KeyTime="0:0:0.7" KeySpline="0,1 0,0" />
                           <SplineDoubleKeyFrame Value="40" KeyTime="0:0:1" KeySpline="0,1 0,0" />
                           <SplineDoubleKeyFrame Value="50" KeyTime="0:0:1.3" KeySpline="0,1 0,0" />
                        </DoubleAnimationUsingKeyFrames.KeyFrames>
                     </DoubleAnimationUsingKeyFrames>
                  </SetterTimeline>
                  <SetterTimeline TargetName="grid" Path="(Grid.RenderTransform).(TranslateTransform.Y)" FillBehavior="HoldEnd">
                     <DoubleAnimationUsingKeyFrames Duration="0:0:1.3" FillBehavior="HoldEnd">
                        <DoubleAnimationUsingKeyFrames.KeyFrames>
                           <SplineDoubleKeyFrame Value="10" KeyTime="0:0:1.3" KeySpline="0,1 1,1" />
                        </DoubleAnimationUsingKeyFrames.KeyFrames>
                     </DoubleAnimationUsingKeyFrames>
                  </SetterTimeline>
               </ParallelTimeline>
            </ControlTemplate.Storyboards>
         </ControlTemplate>
      </Setter.Value>
   </Setter>
</Style>   
more...
http://www.sebura.com
Originally Posted on 8/14/2005 11:32:01 AMContent source: http://longhornblogs.com/rdawson/archive/2005/05/27/14135.aspx