Mega Code Archive

 
Categories / Silverlight / Animations
 

Four Sided Bounce

<UserControl x:Class='SilverlightApplication3.MainPage'     xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'      xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'     xmlns:d='http://schemas.microsoft.com/expression/blend/2008'      xmlns:mc='http://schemas.openxmlformats.org/markup-compatibility/2006'      mc:Ignorable='d'      d:DesignWidth='640'      d:DesignHeight='480'>     <Ellipse Name="elips" Fill="Blue" Width="8" Height="8" />      <UserControl.Triggers>         <EventTrigger RoutedEvent="Canvas.SizeChanged">             <BeginStoryboard>                 <Storyboard TargetName="elips">                     <DoubleAnimation Storyboard.TargetProperty="(Canvas.Left)"                         BeginTime="-0:0:1"                         Duration="0:0:2"                         RepeatBehavior="Forever" AutoReverse="True"                         From="0" To="{Binding ElementName=canv, Path=ActualWidth}" />                     <DoubleAnimation Storyboard.TargetProperty="(Canvas.Top)"                         Duration="0:0:2"                         RepeatBehavior="Forever" AutoReverse="True"                         From="0" To="{Binding ElementName=canv, Path=ActualHeight}" />                 </Storyboard>             </BeginStoryboard>         </EventTrigger>     </UserControl.Triggers> </UserControl>