Mega Code Archive

 
Categories / VB.Net Tutorial / WPF
 

Create an animation using the storyboard

<Window x: Class="StoryboardAnimation"   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   Title="Storyboard Animation" Height="300" Width="300">   <Canvas>     <Rectangle x:Name="rect1" Width="100" Height="50" Fill="Blue">       <Rectangle.Triggers>         <EventTrigger RoutedEvent="Rectangle.Loaded">           <EventTrigger.Actions>             <BeginStoryboard>               <Storyboard>                 <DoubleAnimation                   Storyboard.TargetName="rect1"                   Storyboard.TargetProperty="(Canvas.Left)" From="0" To="200"                   Duration="0:0:5" RepeatBehavior="Forever" AutoReverse="True" />               </Storyboard>             </BeginStoryboard>           </EventTrigger.Actions>         </EventTrigger>       </Rectangle.Triggers>     </Rectangle>   </Canvas> </Window>