<Window x:Class="AnimationTransform" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Animating Translation" Height="300" Width="300"> <Window.Resources> <Style TargetType="{x:Type Rectangle}"> <Setter Property="Width" Value="200" /> <Setter Property="Height" Value="35" /> <Setter Property="RenderTransform"> <Setter.Value> <TranslateTransform /> </Setter.Value> </Setter> <Style.Triggers> <EventTrigger RoutedEvent="Rectangle.MouseEnter"> <EventTrigger.Actions> <BeginStoryboard Name="translateStoryboardBegin"> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="RenderTransform.X" From="0" To="70" Duration="0:0:1" RepeatBehavior="1x" /> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> <EventTrigger RoutedEvent="Rectangle.MouseLeave"> <EventTrigger.Actions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="RenderTransform.X" Duration="0:0:0.5" /> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> </Style.Triggers> </Style> </Window.Resources> <Canvas Margin="10"> <Rectangle Fill="Red" Canvas.Top="0" /> </Canvas> </Window>