Animate Width and Height of a Ellipse

image_pdfimage_print


   
     

<Window x:Class="Main"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="" Height="300" Width="300">
  <Window.Resources>
    <Storyboard x:Key="ellipse1Storyboard" Storyboard.TargetName="ellipse1">
      <ParallelTimeline>
        <DoubleAnimation To="50" Duration="0:0:5" AccelerationRatio="0.25" DecelerationRatio="0.25" Storyboard.TargetProperty="Width" RepeatBehavior="5x" />
        <DoubleAnimation To="50" Duration="0:0:5" AccelerationRatio="0.5" DecelerationRatio="0.25" Storyboard.TargetProperty="Height" RepeatBehavior="5x" SpeedRatio="4" />
      </ParallelTimeline>
    </Storyboard>
  </Window.Resources>
  <Window.Triggers>
    <EventTrigger RoutedEvent="Ellipse.Loaded" SourceName="ellipse1">
      <BeginStoryboard Storyboard="{DynamicResource ellipse1Storyboard}" />
    </EventTrigger>
  </Window.Triggers>
  <Grid>
    <Ellipse x:Name="ellipse1" Margin="10" Width="100" Height="100" Fill="CornflowerBlue" />
  </Grid>
</Window>