FourArrowButton.xaml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <UserControl x:Class="MECF.Framework.UI.Client.ClientBase.UserControls.FourArrowButton"
  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. xmlns:cal="clr-namespace:Caliburn.Micro"
  7. mc:Ignorable="d"
  8. d:DesignHeight="70" d:DesignWidth="70">
  9. <UserControl.Resources>
  10. <ControlTemplate x:Key="ArrowButtonTemplate" TargetType="Button">
  11. <Viewbox>
  12. <Path x:Name="arrowPath"
  13. Data="{TemplateBinding Tag}"
  14. Fill="{Binding ArrowColor, RelativeSource={RelativeSource AncestorType=UserControl}}"
  15. Stretch="Uniform"
  16. RenderTransformOrigin="0.5,0.5">
  17. <Path.RenderTransform>
  18. <ScaleTransform x:Name="scaleTransform" ScaleX="1" ScaleY="1"/>
  19. </Path.RenderTransform>
  20. </Path>
  21. </Viewbox>
  22. <ControlTemplate.Triggers>
  23. <!-- 鼠标悬停动画 -->
  24. <Trigger Property="IsMouseOver" Value="True">
  25. <Trigger.EnterActions>
  26. <BeginStoryboard>
  27. <Storyboard>
  28. <DoubleAnimation Storyboard.TargetName="scaleTransform"
  29. Storyboard.TargetProperty="ScaleX"
  30. To="1.5" Duration="0:0:0.2"/>
  31. <DoubleAnimation Storyboard.TargetName="scaleTransform"
  32. Storyboard.TargetProperty="ScaleY"
  33. To="1.5" Duration="0:0:0.2"/>
  34. </Storyboard>
  35. </BeginStoryboard>
  36. </Trigger.EnterActions>
  37. <Trigger.ExitActions>
  38. <BeginStoryboard>
  39. <Storyboard>
  40. <DoubleAnimation Storyboard.TargetName="scaleTransform"
  41. Storyboard.TargetProperty="ScaleX"
  42. To="1" Duration="0:0:0.1"/>
  43. <DoubleAnimation Storyboard.TargetName="scaleTransform"
  44. Storyboard.TargetProperty="ScaleY"
  45. To="1" Duration="0:0:0.1"/>
  46. </Storyboard>
  47. </BeginStoryboard>
  48. </Trigger.ExitActions>
  49. </Trigger>
  50. <Trigger Property="IsEnabled" Value="false">
  51. <Setter TargetName="arrowPath" Property="Fill" Value="{StaticResource Button_BG_Unable}"/>
  52. </Trigger>
  53. </ControlTemplate.Triggers>
  54. </ControlTemplate>
  55. <!-- 方向箭头路径数据 -->
  56. <Geometry x:Key="UpArrow">M 8 14 L 16 6 24 14 20 14 20 22 12 22 12 14 8 14</Geometry>
  57. <Geometry x:Key="DownArrow">M 8 18 L 12 18 12 10 20 10 20 18 24 18 16 26 8 18</Geometry>
  58. <Geometry x:Key="LeftArrow">M 14 8 L 6 16 14 24 14 20 22 20 22 12 14 12 14 8</Geometry>
  59. <Geometry x:Key="RightArrow">M 18 8 L 18 12 10 12 10 20 18 20 18 24 26 16 18 8</Geometry>
  60. </UserControl.Resources>
  61. <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
  62. <Grid.RowDefinitions>
  63. <RowDefinition Height="Auto"/>
  64. <RowDefinition Height="Auto"/>
  65. <RowDefinition Height="Auto"/>
  66. </Grid.RowDefinitions>
  67. <Grid.ColumnDefinitions>
  68. <ColumnDefinition Width="Auto"/>
  69. <ColumnDefinition Width="Auto"/>
  70. <ColumnDefinition Width="Auto"/>
  71. </Grid.ColumnDefinitions>
  72. <!-- 上箭头 -->
  73. <Button Grid.Row="0" Grid.Column="1"
  74. Template="{StaticResource ArrowButtonTemplate}"
  75. Tag="{StaticResource UpArrow}"
  76. cal:Message.Attach="ArrowClick('Up')"/>
  77. <!--左箭头-->
  78. <Button Grid.Row="1" Grid.Column="0"
  79. Template="{StaticResource ArrowButtonTemplate}"
  80. Tag="{StaticResource LeftArrow}"
  81. cal:Message.Attach="ArrowClick('Left')"/>
  82. <!--下箭头-->
  83. <Button Grid.Row="2" Grid.Column="1"
  84. Template="{StaticResource ArrowButtonTemplate}"
  85. Tag="{StaticResource DownArrow}"
  86. cal:Message.Attach="ArrowClick('Down')"/>
  87. <!--右箭头-->
  88. <Button Grid.Row="1" Grid.Column="2"
  89. Template="{StaticResource ArrowButtonTemplate}"
  90. Tag="{StaticResource RightArrow}"
  91. cal:Message.Attach="ArrowClick('Right')"/>
  92. </Grid>
  93. </UserControl>