Guest User

Untitled

a guest
Mar 24th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. <Page
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. mc:Ignorable="d"
  7. d:DesignHeight="450" d:DesignWidth="800" Title="Page1">
  8. <Canvas>
  9. <Button Canvas.Top="150" Canvas.Left="200" Click="Button_Click">
  10. <Button.RenderTransform>
  11. <RotateTransform x:Name="AnimatedRotateTransform" Angle="0" />
  12. </Button.RenderTransform>
  13. <Button.Triggers>
  14. <EventTrigger RoutedEvent="Loaded">
  15. <EventTrigger.Actions>
  16.  
  17. <BeginStoryboard>
  18. <Storyboard Timeline.DesiredFrameRate="60">
  19. <DoubleAnimation
  20. Storyboard.TargetName="AnimatedRotateTransform"
  21. Storyboard.TargetProperty="Angle"
  22. From="-5"
  23. To="355"
  24. Duration="0:0:0:2"
  25. DecelerationRatio="1"
  26. RepeatBehavior="Forever"/>
  27. </Storyboard>
  28. </BeginStoryboard>
  29.  
  30. </EventTrigger.Actions>
  31. </EventTrigger>
  32. </Button.Triggers>
  33. <Button.Content>
  34. <TextBlock FontSize="50">
  35. Click me!!!
  36. </TextBlock>
  37. </Button.Content>
  38. </Button>
  39. <x:Code>
  40. <![CDATA[
  41. private void Button_Click(object sender, RoutedEventArgs e)
  42. {
  43. System.Windows.Media.Animation.DoubleAnimation animation = new System.Windows.Media.Animation.DoubleAnimation();
  44. animation.From = (sender as Button).ActualHeight;
  45. animation.To = (sender as Button).ActualHeight + 50;
  46. animation.Duration = TimeSpan.FromSeconds(1);
  47.  
  48. (sender as Button).BeginAnimation(HeightProperty, animation);
  49. }
  50. ]]>
  51. </x:Code>
  52. </Canvas>
Add Comment
Please, Sign In to add comment