DecimalButtonStyle.xaml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit">
  4. <Style x:Key="BaseButtonStyle" TargetType="{x:Type ButtonBase}">
  5. <Setter Property="Background" Value="#FFCFCFCF" />
  6. <Setter Property="BorderBrush" Value="{DynamicResource CommonBorderBrush}" />
  7. <Setter Property="HorizontalContentAlignment" Value="Center" />
  8. <Setter Property="VerticalContentAlignment" Value="Center" />
  9. <Setter Property="Padding" Value="0,0,1,1" />
  10. <Setter Property="Template">
  11. <Setter.Value>
  12. <ControlTemplate TargetType="{x:Type ButtonBase}">
  13. <Border x:Name="ContentContainer"
  14. Background="{TemplateBinding Background}"
  15. BorderBrush="{TemplateBinding BorderBrush}"
  16. BorderThickness="{TemplateBinding BorderThickness}"
  17. SnapsToDevicePixels="true">
  18. <ContentPresenter Margin="{TemplateBinding Padding}"
  19. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  20. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  21. RecognizesAccessKey="True"
  22. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  23. </Border>
  24. <ControlTemplate.Triggers>
  25. <Trigger Property="IsKeyboardFocused" Value="true" />
  26. <Trigger Property="Button.IsDefaulted" Value="true" />
  27. <Trigger Property="IsPressed" Value="true" />
  28. <Trigger Property="ToggleButton.IsChecked" Value="true" />
  29. <Trigger Property="IsEnabled" Value="false">
  30. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
  31. </Trigger>
  32. </ControlTemplate.Triggers>
  33. </ControlTemplate>
  34. </Setter.Value>
  35. </Setter>
  36. </Style>
  37. <Style x:Key="RepeatSpinnerStyle"
  38. BasedOn="{StaticResource BaseButtonStyle}"
  39. TargetType="{x:Type RepeatButton}">
  40. <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false" />
  41. </Style>
  42. <Style x:Key="ButtonNewSpinnerStyle" TargetType="{x:Type xctk:ButtonSpinner}">
  43. <Setter Property="BorderThickness" Value="1" />
  44. <Setter Property="IsTabStop" Value="False" />
  45. <Setter Property="HorizontalContentAlignment" Value="Stretch" />
  46. <Setter Property="VerticalContentAlignment" Value="Center" />
  47. <Setter Property="Template">
  48. <Setter.Value>
  49. <ControlTemplate TargetType="{x:Type xctk:ButtonSpinner}">
  50. <Border x:Name="Border"
  51. Background="{TemplateBinding Background}"
  52. BorderBrush="{TemplateBinding BorderBrush}"
  53. BorderThickness="{TemplateBinding BorderThickness}"
  54. SnapsToDevicePixels="True">
  55. <Grid>
  56. <Grid.ColumnDefinitions>
  57. <ColumnDefinition Width="*" MinWidth="20" />
  58. <ColumnDefinition Width="8*" />
  59. <ColumnDefinition Width="*" MinWidth="20" />
  60. </Grid.ColumnDefinitions>
  61. <RepeatButton x:Name="PART_DecreaseButton"
  62. BorderThickness="0,0,1,0"
  63. IsTabStop="{TemplateBinding IsTabStop}"
  64. Style="{DynamicResource RepeatSpinnerStyle}">
  65. <Path Width="10.25"
  66. Height="3.667"
  67. Margin="4"
  68. Data="F1M2,1C2,1 10,1 10,1 10,1 10,3 10,3 10,3 2,3 2,3 2,3 2,1 2,1z"
  69. Fill="{DynamicResource RepeaterContentBrush}"
  70. Stretch="Fill" />
  71. </RepeatButton>
  72. <ContentPresenter Grid.Column="1"
  73. Margin="{TemplateBinding Padding}"
  74. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  75. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  76. Content="{TemplateBinding Content}"
  77. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  78. <RepeatButton x:Name="PART_IncreaseButton"
  79. Grid.Column="2"
  80. BorderThickness="1,0,0,0"
  81. IsTabStop="{TemplateBinding IsTabStop}"
  82. Style="{DynamicResource RepeatSpinnerStyle}">
  83. <Path Width="10.917"
  84. Height="10.417"
  85. Margin="4"
  86. Data="F1M5,2C5,2 7,2 7,2 7,2 7,2.5 7,3.25L7,5 8.75,5C9.5,5 10,5 10,5 10,5 10,7 10,7 10,7 9.5,7 8.75,7L7,7 7,8.75C7,9.5 7,10 7,10 7,10 5,10 5,10 5,10 5,9.5 5,8.75L5,7 3.25,7C2.5,7 2,7 2,7 2,7 2,5 2,5 2,5 2.5,5 3.25,5L5,5 5,3.25C5,2.5,5,2,5,2z"
  87. Fill="{DynamicResource RepeaterContentBrush}"
  88. Stretch="Fill" />
  89. </RepeatButton>
  90. </Grid>
  91. </Border>
  92. <ControlTemplate.Triggers>
  93. <Trigger SourceName="PART_IncreaseButton" Property="IsPressed" Value="True">
  94. <Setter TargetName="PART_IncreaseButton" Property="Background" Value="{DynamicResource ButtonPressBrush}" />
  95. </Trigger>
  96. <Trigger SourceName="PART_DecreaseButton" Property="IsPressed" Value="True">
  97. <Setter TargetName="PART_DecreaseButton" Property="Background" Value="{DynamicResource ButtonPressBrush}" />
  98. </Trigger>
  99. <Trigger SourceName="PART_IncreaseButton" Property="IsEnabled" Value="False" />
  100. <Trigger SourceName="PART_DecreaseButton" Property="IsEnabled" Value="False" />
  101. </ControlTemplate.Triggers>
  102. </ControlTemplate>
  103. </Setter.Value>
  104. </Setter>
  105. </Style>
  106. <!-- 设置数字控件中的样式 -->
  107. <Style x:Key="WatermarkTextBoxStyle" TargetType="{x:Type xctk:WatermarkTextBox}">
  108. <Setter Property="AllowDrop" Value="True" />
  109. <Setter Property="HorizontalContentAlignment" Value="Center" />
  110. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  111. <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
  112. <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
  113. <Setter Property="WatermarkTemplate">
  114. <Setter.Value>
  115. <DataTemplate>
  116. <ContentControl Content="{Binding}" Focusable="False" />
  117. </DataTemplate>
  118. </Setter.Value>
  119. </Setter>
  120. <Setter Property="Template">
  121. <Setter.Value>
  122. <ControlTemplate TargetType="{x:Type xctk:WatermarkTextBox}">
  123. <Grid>
  124. <Border x:Name="Border"
  125. Background="{TemplateBinding Background}"
  126. BorderBrush="{TemplateBinding BorderBrush}"
  127. BorderThickness="{TemplateBinding BorderThickness}"
  128. CornerRadius="1" />
  129. <Border x:Name="MouseOverVisual"
  130. BorderThickness="{TemplateBinding BorderThickness}"
  131. CornerRadius="1"
  132. Opacity="0">
  133. <Border.BorderBrush>
  134. <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
  135. <GradientStop Offset="0.05" Color="#FF5794BF" />
  136. <GradientStop Offset="0.07" Color="#FFB7D5EA" />
  137. <GradientStop Offset="1" Color="#FFC7E2F1" />
  138. </LinearGradientBrush>
  139. </Border.BorderBrush>
  140. </Border>
  141. <Border x:Name="FocusVisual"
  142. BorderThickness="{TemplateBinding BorderThickness}"
  143. CornerRadius="1"
  144. Opacity="0">
  145. <Border.BorderBrush>
  146. <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
  147. <GradientStop Offset="0.05" Color="#FF3D7BAD" />
  148. <GradientStop Offset="0.07" Color="#FFA4C9E3" />
  149. <GradientStop Offset="1" Color="#FFB7D9ED" />
  150. </LinearGradientBrush>
  151. </Border.BorderBrush>
  152. </Border>
  153. <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  154. <ContentPresenter x:Name="PART_WatermarkHost"
  155. Margin="{TemplateBinding Padding}"
  156. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  157. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  158. Content="{TemplateBinding Watermark}"
  159. ContentTemplate="{TemplateBinding WatermarkTemplate}"
  160. IsHitTestVisible="False"
  161. Visibility="Collapsed" />
  162. </Grid>
  163. <ControlTemplate.Triggers>
  164. <MultiTrigger>
  165. <MultiTrigger.Conditions>
  166. <Condition Property="IsFocused" Value="False" />
  167. <Condition Property="Text" Value="" />
  168. </MultiTrigger.Conditions>
  169. <Setter TargetName="PART_WatermarkHost" Property="Visibility" Value="Visible" />
  170. </MultiTrigger>
  171. <Trigger Property="IsMouseOver" Value="True">
  172. <Setter TargetName="MouseOverVisual" Property="Opacity" Value="1" />
  173. </Trigger>
  174. <Trigger Property="IsFocused" Value="True">
  175. <Setter TargetName="FocusVisual" Property="Opacity" Value="1" />
  176. </Trigger>
  177. </ControlTemplate.Triggers>
  178. </ControlTemplate>
  179. </Setter.Value>
  180. </Setter>
  181. </Style>
  182. <Style x:Key="DecimalNewUpDownStyle" TargetType="{x:Type xctk:DecimalUpDown}">
  183. <Setter Property="BorderThickness" Value="1" />
  184. <Setter Property="Padding" Value="0" />
  185. <Setter Property="BorderBrush" Value="{DynamicResource CommonBorderBrush}" />
  186. <Setter Property="ClipValueToMinMax" Value="True" />
  187. <Setter Property="HorizontalContentAlignment" Value="Center" />
  188. <Setter Property="IsTabStop" Value="False" />
  189. <Setter Property="VerticalContentAlignment" Value="Center" />
  190. <Setter Property="TextAlignment" Value="Right" />
  191. <Setter Property="Focusable" Value="True" />
  192. <Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
  193. <Setter Property="WatermarkTemplate">
  194. <Setter.Value>
  195. <DataTemplate>
  196. <ContentControl Margin="0,0,3,0"
  197. HorizontalContentAlignment="Center"
  198. Content="{Binding}"
  199. Focusable="False" />
  200. </DataTemplate>
  201. </Setter.Value>
  202. </Setter>
  203. <Setter Property="Template">
  204. <Setter.Value>
  205. <ControlTemplate TargetType="{x:Type xctk:DecimalUpDown}">
  206. <Grid>
  207. <Rectangle Name="OutSideBorder"
  208. HorizontalAlignment="Stretch"
  209. VerticalAlignment="Stretch"
  210. SnapsToDevicePixels="true"
  211. Stroke="{DynamicResource FocusVisualBrush}"
  212. StrokeDashArray="1,2"
  213. StrokeThickness="1"
  214. Visibility="Collapsed" />
  215. <Border Margin="1"
  216. BorderBrush="{TemplateBinding BorderBrush}"
  217. BorderThickness="1"
  218. CornerRadius="4">
  219. <Grid>
  220. <xctk:ButtonSpinner x:Name="PART_Spinner"
  221. AllowSpin="{Binding AllowSpin,
  222. RelativeSource={RelativeSource TemplatedParent}}"
  223. Background="{TemplateBinding Background}"
  224. BorderBrush="{TemplateBinding BorderBrush}"
  225. BorderThickness="{TemplateBinding BorderThickness}"
  226. ShowButtonSpinner="{Binding ShowButtonSpinner,
  227. RelativeSource={RelativeSource TemplatedParent}}"
  228. Style="{DynamicResource ButtonNewSpinnerStyle}">
  229. <xctk:WatermarkTextBox x:Name="PART_TextBox"
  230. MinWidth="20"
  231. HorizontalAlignment="Center"
  232. HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
  233. VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
  234. AcceptsReturn="False"
  235. AutoMoveFocus="{Binding AutoMoveFocus,
  236. RelativeSource={RelativeSource TemplatedParent}}"
  237. AutoSelectBehavior="{Binding AutoSelectBehavior,
  238. RelativeSource={RelativeSource TemplatedParent}}"
  239. Background="Transparent"
  240. BorderBrush="Transparent"
  241. BorderThickness="0"
  242. ContextMenu="{TemplateBinding ContextMenu}"
  243. FontFamily="{TemplateBinding FontFamily}"
  244. FontSize="{TemplateBinding FontSize}"
  245. FontStretch="{TemplateBinding FontStretch}"
  246. FontStyle="{TemplateBinding FontStyle}"
  247. FontWeight="{TemplateBinding FontWeight}"
  248. Foreground="{TemplateBinding Foreground}"
  249. IsReadOnly="{Binding IsReadOnly,
  250. RelativeSource={RelativeSource TemplatedParent}}"
  251. Padding="{TemplateBinding Padding}"
  252. SelectAllOnGotFocus="{Binding SelectAllOnGotFocus,
  253. RelativeSource={RelativeSource TemplatedParent}}"
  254. Style="{StaticResource WatermarkTextBoxStyle}"
  255. TabIndex="{TemplateBinding TabIndex}"
  256. TextAlignment="{Binding TextAlignment,
  257. RelativeSource={RelativeSource TemplatedParent}}"
  258. TextWrapping="NoWrap"
  259. Watermark="{Binding Watermark,
  260. RelativeSource={RelativeSource TemplatedParent}}"
  261. WatermarkTemplate="{Binding WatermarkTemplate,
  262. RelativeSource={RelativeSource TemplatedParent}}" />
  263. </xctk:ButtonSpinner>
  264. <Rectangle x:Name="enableRectangle"
  265. Grid.ColumnSpan="3"
  266. Fill="{DynamicResource MuchinfoBrush6}"
  267. Opacity="0.7"
  268. Visibility="Collapsed" />
  269. </Grid>
  270. </Border>
  271. </Grid>
  272. <ControlTemplate.Triggers>
  273. <Trigger Property="IsEnabled" Value="False">
  274. <!-- <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/> -->
  275. <Setter TargetName="enableRectangle" Property="Visibility" Value="Visible" />
  276. </Trigger>
  277. <Trigger Property="IsFocused" Value="True">
  278. <Setter TargetName="OutSideBorder" Property="Visibility" Value="Visible" />
  279. <Setter TargetName="PART_TextBox" Property="FocusManager.FocusedElement" Value="{Binding ElementName=PART_TextBox}" />
  280. </Trigger>
  281. <Trigger SourceName="PART_TextBox" Property="IsFocused" Value="True">
  282. <Setter TargetName="OutSideBorder" Property="Visibility" Value="Visible" />
  283. </Trigger>
  284. <Trigger SourceName="PART_Spinner" Property="IsFocused" Value="True">
  285. <Setter TargetName="OutSideBorder" Property="Visibility" Value="Visible" />
  286. <Setter TargetName="PART_TextBox" Property="FocusManager.FocusedElement" Value="{Binding ElementName=PART_TextBox}" />
  287. </Trigger>
  288. </ControlTemplate.Triggers>
  289. </ControlTemplate>
  290. </Setter.Value>
  291. </Setter>
  292. </Style>
  293. </ResourceDictionary>