Frame Rates : Frame Animation « Windows Presentation Foundation « VB.Net Tutorial






<Window x:Class="Animation.FrameRates"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="FrameRates" Height="410" Width="400">
  <Window.Resources>
    <BeginStoryboard x:Key="beginStoryboard">
      <Storyboard Timeline.DesiredFrameRate="{Binding ElementName=txtFrameRate,Path=Text}">
        <DoubleAnimation Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(Canvas.Left)"
                         From="0" To="300" Duration="0:0:5">
        </DoubleAnimation>
        <DoubleAnimation Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(Canvas.Top)"
                         From="300" To="0" AutoReverse="True" Duration="0:0:2.5"
                         DecelerationRatio="1">
        </DoubleAnimation>
      </Storyboard>
    </BeginStoryboard>
  </Window.Resources>
  
  <Window.Triggers>
    <EventTrigger RoutedEvent="Window.Loaded">
      <EventTrigger.Actions>
        <StaticResource ResourceKey="beginStoryboard"></StaticResource>
      </EventTrigger.Actions>
    </EventTrigger>
  </Window.Triggers>

  <Grid Background="LightGoldenrodYellow" >
    <Grid.RowDefinitions>
      <RowDefinition></RowDefinition>
      <RowDefinition Height="Auto"></RowDefinition>
      <RowDefinition Height="Auto"></RowDefinition>
    </Grid.RowDefinitions>

    <Border Background="White" BorderBrush="DarkGray" BorderThickness="3" Width="300" Height="300" HorizontalAlignment="Center" VerticalAlignment="Center">
      <Canvas ClipToBounds="True">
        <Ellipse Name="ellipse" Fill="Red" Width="10" Height="10"></Ellipse>
      </Canvas>
    </Border>

    <TextBox Grid.Column="2" Width="50" Name="txtFrameRate">60</TextBox>
    <Button Grid.Row="2" HorizontalAlignment="Center" Padding="3" Margin="3">
      <Button.Triggers>
        <EventTrigger RoutedEvent="Button.Click">
          <StaticResource ResourceKey="beginStoryboard"></StaticResource>
        </EventTrigger>
      </Button.Triggers>
      <Button.Content>
        Repeat
      </Button.Content>
    </Button>
  </Grid>
   
</Window>
WPF Frame Rates








16.110.Frame Animation
16.110.1.Simple Key Frame AnimationSimple Key Frame Animation
16.110.2.KeyFrame Point AnimationKeyFrame Point Animation
16.110.3.Use DiscreteDoubleKeyFrame to switch textUse DiscreteDoubleKeyFrame to switch text
16.110.4.Use SplineDoubleKeyFrame to rotate a ButtonUse SplineDoubleKeyFrame to rotate a Button
16.110.5.Key frame animationKey frame animation
16.110.6.Key frame spline animationKey frame spline animation
16.110.7.Animated Button With Discrete Key FramesAnimated Button With Discrete Key Frames
16.110.8.SplineDoubleKeyFrame and KeySplineSplineDoubleKeyFrame and KeySpline
16.110.9.Limit the Frame Rate for All Animations in an ApplicationLimit the Frame Rate for All Animations in an Application
16.110.10.Frame RatesFrame Rates
16.110.11.String Animation Using Key FramesString Animation Using Key Frames