NumericUpDownStyles.xaml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <Styles xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:suki="https://github.com/kikipoulet/SukiUI"
  4. xmlns:theme="clr-namespace:SukiUI.Theme">
  5. <Design.PreviewWith>
  6. <Border Padding="20">
  7. <StackPanel Orientation="Horizontal" Spacing="5">
  8. <NumericUpDown Value="4" />
  9. <TextBox Classes="NoShadow" Text="test" />
  10. </StackPanel>
  11. </Border>
  12. </Design.PreviewWith>
  13. <Style Selector="NumericUpDown">
  14. <Setter Property="BorderThickness" Value="0,0,0,0" />
  15. <Setter Property="BorderBrush" Value="{DynamicResource SukiControlBorderBrush}" />
  16. <Setter Property="CornerRadius" Value="{DynamicResource SmallCornerRadius}" />
  17. <Setter Property="Background" Value="{DynamicResource SukiBackground}" />
  18. <Setter Property="VerticalContentAlignment" Value="Center" />
  19. <Setter Property="Padding" Value="4" />
  20. <Setter Property="Template">
  21. <ControlTemplate>
  22. <suki:GlassCard Padding="0"
  23. VerticalAlignment="Center"
  24. Classes="Discrete"
  25. CornerRadius="{TemplateBinding CornerRadius}">
  26. <ButtonSpinner Name="PART_Spinner"
  27. Height="26"
  28. Margin="5,4"
  29. HorizontalContentAlignment="Stretch"
  30. VerticalContentAlignment="Stretch"
  31. AllowSpin="{TemplateBinding AllowSpin}"
  32. Background="{TemplateBinding Background}"
  33. BorderBrush="{TemplateBinding BorderBrush}"
  34. BorderThickness="{TemplateBinding BorderThickness}"
  35. ButtonSpinnerLocation="{TemplateBinding ButtonSpinnerLocation}"
  36. CornerRadius="{TemplateBinding CornerRadius}"
  37. ShowButtonSpinner="{TemplateBinding ShowButtonSpinner}">
  38. <Grid ColumnDefinitions="*,Auto">
  39. <TextBox Name="PART_TextBox"
  40. MinWidth="20"
  41. Margin="-5,-5,-5,-6"
  42. Padding="{TemplateBinding Padding}"
  43. HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
  44. VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
  45. theme:TextBoxExtensions.AddDeleteButton="False"
  46. AcceptsReturn="False"
  47. Background="Transparent"
  48. BorderThickness="0"
  49. Classes="NoShadow"
  50. CornerRadius="0"
  51. DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
  52. IsReadOnly="{TemplateBinding IsReadOnly}"
  53. Text="{TemplateBinding Text}"
  54. TextWrapping="NoWrap"
  55. Watermark="{TemplateBinding Watermark}" />
  56. <TextBlock Grid.Column="1"
  57. Margin="0,1,9,0"
  58. VerticalAlignment="Center"
  59. FontSize="13"
  60. Foreground="{DynamicResource SukiLowText}"
  61. Text="{TemplateBinding theme:NumericUpDownExtensions.Unit}" />
  62. </Grid>
  63. </ButtonSpinner>
  64. </suki:GlassCard>
  65. </ControlTemplate>
  66. </Setter>
  67. </Style>
  68. <Style Selector="NumericUpDown /template/ ButtonSpinner /template/ Border">
  69. <Setter Property="CornerRadius" Value="{DynamicResource SmallCornerRadius}" />
  70. </Style>
  71. <Style Selector="NumericUpDown /template/ Border">
  72. <Setter Property="BorderThickness" Value="0" />
  73. </Style>
  74. <Style Selector="NumericUpDown:pointerover /template/ TextBox">
  75. <Setter Property="Background" Value="Transparent" />
  76. <Setter Property="BorderThickness" Value="0" />
  77. <Setter Property="BorderBrush" Value="{DynamicResource SukiControlBorderBrush}" />
  78. </Style>
  79. <Style Selector="NumericUpDown:pressed /template/ TextBox">
  80. <Setter Property="Background" Value="Transparent" />
  81. <Setter Property="BorderBrush" Value="{DynamicResource SukiControlBorderBrush}" />
  82. </Style>
  83. <Style Selector="NumericUpDown:disabled">
  84. <Setter Property="Foreground" Value="{DynamicResource SukiDisabledText}" />
  85. </Style>
  86. <Style Selector="RepeatButton:pointerover">
  87. <Setter Property="BorderBrush" Value="{DynamicResource SukiBorderBrush}" />
  88. </Style>
  89. <Style Selector="ButtonSpinner">
  90. <Setter Property="Background" Value="Transparent" />
  91. <Setter Property="BorderBrush" Value="{DynamicResource SukiControlBorderBrush}" />
  92. <Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}" />
  93. <Setter Property="HorizontalContentAlignment" Value="Stretch" />
  94. <Setter Property="VerticalContentAlignment" Value="Center" />
  95. <Setter Property="Focusable" Value="True" />
  96. <Setter Property="Template">
  97. <ControlTemplate>
  98. <DataValidationErrors>
  99. <Border Name="border"
  100. Margin="{TemplateBinding Padding}"
  101. HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
  102. VerticalAlignment="{TemplateBinding VerticalAlignment}"
  103. Background="{TemplateBinding Background}"
  104. BorderBrush="{TemplateBinding BorderBrush}"
  105. BorderThickness="{TemplateBinding BorderThickness}"
  106. CornerRadius="{TemplateBinding CornerRadius}">
  107. <DockPanel>
  108. <UniformGrid Name="PART_SpinnerPanel"
  109. DockPanel.Dock="Right"
  110. IsVisible="{TemplateBinding ShowButtonSpinner}"
  111. Rows="2">
  112. <RepeatButton Name="PART_IncreaseButton"
  113. BorderThickness="0"
  114. Theme="{StaticResource SimpleButtonSpinnerRepeatButton}">
  115. <Path Width="8"
  116. Height="4"
  117. HorizontalAlignment="Center"
  118. VerticalAlignment="Center"
  119. Data="M0,5 L4.5,.5 9,5 6,5 4.5,3.5 3,5 z"
  120. Fill="{DynamicResource SukiText}"
  121. Stretch="Uniform" />
  122. </RepeatButton>
  123. <RepeatButton Name="PART_DecreaseButton"
  124. BorderThickness="0"
  125. Theme="{StaticResource SimpleButtonSpinnerRepeatButton}">
  126. <Path Width="8"
  127. Height="4"
  128. HorizontalAlignment="Center"
  129. VerticalAlignment="Center"
  130. Data="M0,0 L3,0 4.5,1.5 6,0 9,0 4.5,4.5 z"
  131. Fill="{DynamicResource SukiText}"
  132. Stretch="Uniform" />
  133. </RepeatButton>
  134. </UniformGrid>
  135. <ContentPresenter Name="PART_ContentPresenter"
  136. Padding="{TemplateBinding Padding}"
  137. HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
  138. VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
  139. Content="{TemplateBinding Content}"
  140. ContentTemplate="{TemplateBinding ContentTemplate}" />
  141. </DockPanel>
  142. </Border>
  143. </DataValidationErrors>
  144. </ControlTemplate>
  145. </Setter>
  146. <Style Selector="^:left">
  147. <Style Selector="^ /template/ StackPanel#PART_SpinnerPanel">
  148. <Setter Property="DockPanel.Dock" Value="Left" />
  149. </Style>
  150. </Style>
  151. <Style Selector="^:pointerover /template/ Border#border">
  152. <Setter Property="BorderBrush" Value="{DynamicResource SukiBorderBrush}" />
  153. </Style>
  154. <Style Selector="^:focus /template/ Border#border">
  155. <Setter Property="BorderBrush" Value="{DynamicResource SukiBorderBrush}" />
  156. </Style>
  157. <Style Selector="^:error /template/ Border#border">
  158. <Setter Property="BorderBrush" Value="{DynamicResource SukiBorderBrush}" />
  159. </Style>
  160. </Style>
  161. </Styles>