Mega Code Archive

 
Categories / C# / WPF
 

Animate Width and Height of a Rectangle

<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="rect1Storyboard" Storyboard.TargetName="rect1">       <ParallelTimeline>         <DoubleAnimation To="50" Duration="0:0:10" FillBehavior="Stop" Storyboard.TargetProperty="Width" />         <DoubleAnimation To="50" Duration="0:0:5" FillBehavior="HoldEnd" AccelerationRatio="0.5" DecelerationRatio="0.25" Storyboard.TargetProperty="Height" />       </ParallelTimeline>     </Storyboard>   </Window.Resources>   <Window.Triggers>     <EventTrigger RoutedEvent="Rectangle.Loaded" SourceName="rect1">       <BeginStoryboard Storyboard="{StaticResource rect1Storyboard}" />     </EventTrigger>   </Window.Triggers>   <Grid>     <Rectangle x:Name="rect1" Margin="10" Width="100" Height="100" Fill="Firebrick" Grid.Column="1" />   </Grid> </Window>