Frame Rates
<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>