2 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4 Title="Button with Animated Scale Example"
8 <Style x:Key="button" TargetType="{x:Type Button}">
10 <!-- This ScaleTransform is targeted by the Event Trigger. -->
11 <Setter Property="RenderTransform">
13 <ScaleTransform CenterX="0" CenterY="0" ScaleX="1" ScaleY="1" />
17 <!-- Applies the ScaleTransform to the button's center. -->
18 <Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
20 <!-- Enlarge the button when the mouse enters. -->
22 <EventTrigger RoutedEvent="Mouse.MouseEnter">
23 <EventTrigger.Actions>
27 Storyboard.TargetProperty="RenderTransform.ScaleX"
28 Duration="0:0:0.5" To="1.25" AccelerationRatio="0.9" />
30 Storyboard.TargetProperty="RenderTransform.ScaleY"
31 Duration="0:0:0.5" To="1.25" AccelerationRatio="0.9" />
34 </EventTrigger.Actions>
37 <!-- Return the button to its orginal size when the mouse leaves. -->
38 <EventTrigger RoutedEvent="Mouse.MouseLeave">
39 <EventTrigger.Actions>
43 Storyboard.TargetProperty="RenderTransform.ScaleX"
44 Duration="0:0:0.5" To="1" AccelerationRatio=".9" />
46 Storyboard.TargetProperty="RenderTransform.ScaleY"
47 Duration="0:0:0.5" To="1" AccelerationRatio=".9" />
50 </EventTrigger.Actions>
58 <Border Width="500" Margin="25" BorderBrush="Orange"
59 BorderThickness="2" CornerRadius="10"
60 Padding="10,10,10,10" Background="White">
61 <TextBlock TextWrapping="Wrap" TextAlignment="Left" FontWeight="Bold">
62 This example animates a ScaleTransform
63 applied to the RenderTransform property of a Button. When the mouse
64 enters the button, it grows. When the mouse leaves the button, it is
65 animated back to its original size.
69 <Button Style="{StaticResource button}"
70 FontSize="24" Content="Button"
71 HorizontalAlignment="Center" />