Mega Code Archive

 
Categories / C# / WPF
 

Trigger animation with Rectangle MouseEnter

<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">   <Grid>     <Rectangle Height="100" Width="100" Fill="Firebrick" Stroke="Black" StrokeThickness="1">       <Rectangle.Style>         <Style TargetType="Rectangle">           <Style.Triggers>             <EventTrigger RoutedEvent="Rectangle.MouseEnter">               <BeginStoryboard>                 <Storyboard>                   <ParallelTimeline RepeatBehavior="Forever" AutoReverse="True">                     <DoubleAnimation Storyboard.TargetProperty="Width" To="150" />                     <DoubleAnimation Storyboard.TargetProperty="Height" To="150" />                     <ColorAnimation Storyboard.TargetProperty="Fill.Color" To="Orange" />                   </ParallelTimeline>                 </Storyboard>               </BeginStoryboard>             </EventTrigger>           </Style.Triggers>         </Style>       </Rectangle.Style>     </Rectangle>   </Grid> </Window>