Guest User

Untitled

a guest
Jan 15th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. <Image Grid.Column="2" Tap="ArrowDownImg_Tap" x:Name="ArrowDownImg" Margin="0,-10,-33,0" Height="40" Width="40" Source="/Images/appbar.arrow.down.circle.rest.png" />
  2.  
  3. private void ArrowDownImg_Tap(object sender, System.Windows.Input.GestureEventArgs e)
  4. {
  5. Duration duration = new Duration(TimeSpan.FromMilliseconds(500));
  6. Storyboard sb = new Storyboard();
  7. sb.Duration = duration;
  8.  
  9. DoubleAnimation da = new DoubleAnimation();
  10. da.Duration = duration;
  11.  
  12. sb.Children.Add(da);
  13.  
  14. RotateTransform rt = new RotateTransform();
  15.  
  16. Storyboard.SetTarget(da, rt);
  17. Storyboard.SetTargetProperty(da, new PropertyPath("Angle"));
  18. da.To = 180;
  19.  
  20. ImageShowHide.RenderTransform = rt;
  21. ImageShowHide.RenderTransformOrigin = new Point(0.5, 0.5);
  22.  
  23. sb.Begin();
  24. }
  25.  
  26. <Style TargetType="ToggleButton" x:Key="FlipButton">
  27. <Setter Property="Template">
  28. <Setter.Value>
  29. <ControlTemplate TargetType="ToggleButton">
  30. <Grid>
  31. <VisualStateManager.VisualStateGroups>
  32. <VisualStateGroup x:Name="CheckStates">
  33. <VisualState x:Name="Checked">
  34. <Storyboard>
  35. <DoubleAnimation Duration="0" Storyboard.TargetName="rotate" Storyboard.TargetProperty="(RotateTransform.Angle)" To="180" />
  36. </Storyboard>
  37. </VisualState>
  38. <VisualState x:Name="Unchecked">
  39. <Storyboard>
  40. <DoubleAnimation Duration="0" Storyboard.TargetName="rotate" Storyboard.TargetProperty="(RotateTransform.Angle)" To="0" />
  41. </Storyboard>
  42. </VisualState>
  43. </VisualStateGroup>
  44. </VisualStateManager.VisualStateGroups>
  45. <ContentPresenter Content="{TemplateBinding Content}">
  46. <ContentPresenter.RenderTransform>
  47. <RotateTransform x:Name="rotate" CenterX="0.5" CenterY="0.5" />
  48. </ContentPresenter.RenderTransform>
  49. </ContentPresenter>
  50. </Grid>
  51. </ControlTemplate>
  52. </Setter.Value>
  53. </Setter>
  54. </Style>
  55.  
  56. <ToggleButton x:Name="MyToggleButton" Style="{StaticResource FlipButton}">
  57. <ToggleButton.Content>
  58. <Image Source="/Images/appbar.arrow.down.circle.rest.png" />
  59. </ToggleButton.Content>
  60. </ToggleButton>
  61.  
  62. <TextBlock Text="Hello world" Visibility="{Binding ElementName=MyToggleButton,Path=IsChecked,Converter={StaticResource ValueConverterBoolToVis}}" />
  63.  
  64. public class ValueConverterBoolToVis : IValueConverter
  65. {
  66. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  67. {
  68. return ((bool)value) ? Visibility.Visible : Visibility.Collapsed;
  69. }
  70.  
  71. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  72. {
  73. throw new NotImplementedException();
  74. }
  75. }
  76.  
  77. <local:ValueConverterBoolToVis x:Key="local:ValueConverterBoolToVis" />
Add Comment
Please, Sign In to add comment