终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RecToggleButton.xaml 11 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  2. <!--#region 编辑开关 ToggleButton 样式-->
  3. <Style x:Key="EditToggleButtonStyle" TargetType="{x:Type ToggleButton}">
  4. <Setter Property="Template">
  5. <Setter.Value>
  6. <ControlTemplate TargetType="{x:Type ToggleButton}">
  7. <Grid>
  8. <Border
  9. x:Name="border2"
  10. Width="{TemplateBinding Width}"
  11. Height="{TemplateBinding Height}"
  12. Margin="{TemplateBinding Padding}"
  13. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  14. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  15. Background="Transparent">
  16. <ContentPresenter
  17. Margin="{TemplateBinding Padding}"
  18. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  19. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  20. RecognizesAccessKey="True"
  21. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  22. </Border>
  23. </Grid>
  24. <ControlTemplate.Triggers>
  25. <!--<Trigger Property="IsPressed" Value="true">
  26. <Setter Property="Background" Value="#FFd2e7f4" />
  27. </Trigger>-->
  28. <!-- 控件选中 -->
  29. <Trigger Property="IsChecked" Value="true">
  30. <Setter Property="Foreground" Value="#ff1002E9" />
  31. </Trigger>
  32. <!-- 控件未选中 -->
  33. <Trigger Property="IsChecked" Value="false">
  34. <Setter Property="Foreground" Value="#ff2AB2E7" />
  35. </Trigger>
  36. <!-- 鼠标进入 -->
  37. <Trigger Property="IsMouseOver" Value="True">
  38. <Setter TargetName="border2" Property="Background" Value="#332AB2E7" />
  39. </Trigger>
  40. <!-- 控件禁用 -->
  41. <Trigger Property="IsEnabled" Value="false">
  42. <Setter Property="Foreground" Value="#662AB2E7" />
  43. </Trigger>
  44. <!-- 控件启用 -->
  45. <Trigger Property="IsEnabled" Value="True">
  46. <Setter Property="Foreground" Value="#ff2AB2E7" />
  47. </Trigger>
  48. </ControlTemplate.Triggers>
  49. </ControlTemplate>
  50. </Setter.Value>
  51. </Setter>
  52. </Style>
  53. <!--#endregion-->
  54. <!--#region 切换开关 ToggleButton 样式-->
  55. <Style x:Key="SwitchToggleButtonStyle" TargetType="{x:Type ToggleButton}">
  56. <Setter Property="Template">
  57. <Setter.Value>
  58. <ControlTemplate TargetType="{x:Type ToggleButton}">
  59. <Viewbox>
  60. <Grid x:Name="gr" Opacity="0.8">
  61. <Border
  62. x:Name="border2"
  63. Width="{TemplateBinding Width}"
  64. Height="{TemplateBinding Height}"
  65. HorizontalAlignment="Left"
  66. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  67. Background="Red"
  68. BorderBrush="{TemplateBinding BorderBrush}"
  69. CornerRadius="15">
  70. <ContentPresenter
  71. Margin="{TemplateBinding Padding}"
  72. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  73. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  74. RecognizesAccessKey="True"
  75. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  76. </Border>
  77. <Ellipse
  78. Name="ell"
  79. Width="{TemplateBinding Height}"
  80. Height="{TemplateBinding Height}"
  81. Margin="0"
  82. HorizontalAlignment="Left"
  83. VerticalAlignment="Center"
  84. Fill="#ddd" />
  85. <TextBlock
  86. Name="tb"
  87. Margin="10,0,10,0"
  88. HorizontalAlignment="Center"
  89. VerticalAlignment="Center"
  90. Foreground="White"
  91. Text="开" />
  92. </Grid>
  93. </Viewbox>
  94. <ControlTemplate.Triggers>
  95. <!-- 控件选中 -->
  96. <Trigger Property="IsChecked" Value="true">
  97. <Setter TargetName="ell" Property="HorizontalAlignment" Value="Right" />
  98. <Setter TargetName="border2" Property="Background" Value="#00c2f4" />
  99. <Setter TargetName="tb" Property="Text" Value="关" />
  100. <Setter TargetName="tb" Property="Margin" Value="0,0,15,0" />
  101. </Trigger>
  102. <!-- 控件未选中 -->
  103. <Trigger Property="IsChecked" Value="false">
  104. <Setter TargetName="border2" Property="Background" Value="gray" />
  105. <Setter TargetName="tb" Property="Text" Value="开" />
  106. <Setter TargetName="tb" Property="Margin" Value="15,0,0,0" />
  107. </Trigger>
  108. <!-- 鼠标进入 -->
  109. <Trigger Property="IsMouseOver" Value="True">
  110. <Setter TargetName="gr" Property="Opacity" Value="1" />
  111. </Trigger>
  112. <!-- 控件禁用 -->
  113. <Trigger Property="IsEnabled" Value="false">
  114. <Setter TargetName="gr" Property="Opacity" Value="0.5" />
  115. </Trigger>
  116. <!-- 控件启用 -->
  117. <Trigger Property="IsEnabled" Value="True">
  118. <Setter TargetName="gr" Property="Opacity" Value="0.8" />
  119. </Trigger>
  120. </ControlTemplate.Triggers>
  121. </ControlTemplate>
  122. </Setter.Value>
  123. </Setter>
  124. </Style>
  125. <!--#endregion-->
  126. <!--#region 切换开关 ToggleButton 样式-->
  127. <Style x:Key="SwitchToggleButtonStyle1" TargetType="{x:Type ToggleButton}">
  128. <Setter Property="Template">
  129. <Setter.Value>
  130. <ControlTemplate TargetType="{x:Type ToggleButton}">
  131. <Viewbox>
  132. <Grid x:Name="gr" Opacity="0.8">
  133. <Border
  134. x:Name="border2"
  135. Width="{TemplateBinding Width}"
  136. Height="{TemplateBinding Height}"
  137. HorizontalAlignment="Left"
  138. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  139. Background="Red"
  140. BorderBrush="{TemplateBinding BorderBrush}"
  141. CornerRadius="15">
  142. <ContentPresenter
  143. Margin="{TemplateBinding Padding}"
  144. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  145. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  146. RecognizesAccessKey="True"
  147. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  148. Visibility="Collapsed" />
  149. </Border>
  150. <Ellipse
  151. Name="ell"
  152. Width="{TemplateBinding Height}"
  153. Height="{TemplateBinding Height}"
  154. Margin="0"
  155. HorizontalAlignment="Left"
  156. VerticalAlignment="Center"
  157. Fill="#ddd" />
  158. <TextBlock
  159. Name="tb"
  160. Margin="10,0,10,0"
  161. HorizontalAlignment="Center"
  162. VerticalAlignment="Center"
  163. Foreground="White"
  164. Text="{TemplateBinding Content}" />
  165. </Grid>
  166. </Viewbox>
  167. <ControlTemplate.Triggers>
  168. <!-- 控件选中 -->
  169. <Trigger Property="IsChecked" Value="true">
  170. <Setter TargetName="ell" Property="HorizontalAlignment" Value="Right" />
  171. <Setter TargetName="border2" Property="Background" Value="#00c2f4" />
  172. <Setter TargetName="tb" Property="Margin" Value="0,0,15,0" />
  173. </Trigger>
  174. <!-- 控件未选中 -->
  175. <Trigger Property="IsChecked" Value="false">
  176. <Setter TargetName="border2" Property="Background" Value="gray" />
  177. <Setter TargetName="tb" Property="Margin" Value="15,0,0,0" />
  178. </Trigger>
  179. <!-- 鼠标进入 -->
  180. <Trigger Property="IsMouseOver" Value="True">
  181. <Setter TargetName="gr" Property="Opacity" Value="1" />
  182. </Trigger>
  183. <!-- 控件禁用 -->
  184. <Trigger Property="IsEnabled" Value="false">
  185. <Setter TargetName="gr" Property="Opacity" Value="0.5" />
  186. </Trigger>
  187. <!-- 控件启用 -->
  188. <Trigger Property="IsEnabled" Value="True">
  189. <Setter TargetName="gr" Property="Opacity" Value="0.8" />
  190. </Trigger>
  191. </ControlTemplate.Triggers>
  192. </ControlTemplate>
  193. </Setter.Value>
  194. </Setter>
  195. </Style>
  196. <!--#endregion-->
  197. </ResourceDictionary>