XAML code to rotate a button on click.

Abhisek
Posted by Abhisek under WPF category on | Views : 6878
Write the following codes into XamlPad.It will rotate the button 360 degrees in 5 second.

<Page 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Background="White" Margin="50">
<StackPanel>

<Button Content="Click Me" Width="200"
RenderTransformOrigin="0.5,0.5">
<Button.RenderTransform>
<RotateTransform x:Name="AnimatedRotateTransform" Angle="0" />
</Button.RenderTransform>
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="AnimatedRatateTransform"
Storyboard.TargetProperty="Angle"
To="360" Duration="0:0:5" FillBehavior="Stop"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
</StackPanel>
</Page>

Comments or Responses

Login to post response