CheckBoxStyles.axaml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  2. xmlns:suki="https://github.com/kikipoulet/SukiUI">
  3. <Design.PreviewWith>
  4. <Border Padding="20" Background="White">
  5. <StackPanel Spacing="20">
  6. <CheckBox>Unchecked</CheckBox>
  7. <CheckBox IsChecked="True">Checked</CheckBox>
  8. <CheckBox IsChecked="{x:Null}" IsThreeState="True">Indeterminate</CheckBox>
  9. </StackPanel>
  10. </Border>
  11. </Design.PreviewWith>
  12. <Style Selector="CheckBox AccessText">
  13. <Setter Property="Foreground" Value="{DynamicResource SukiText}" />
  14. </Style>
  15. <Style Selector="CheckBox">
  16. <Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}" />
  17. <Setter Property="Background" Value="{DynamicResource SukiCardBackground}" />
  18. <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}" />
  19. <Setter Property="BorderThickness" Value="0.5" />
  20. <Setter Property="Padding" Value="10,1,0,0" />
  21. <Setter Property="VerticalContentAlignment" Value="Center" />
  22. <Setter Property="FontSize" Value="14" />
  23. <Setter Property="HorizontalContentAlignment" Value="Left" />
  24. <Setter Property="Template">
  25. <ControlTemplate>
  26. <Grid ColumnDefinitions="Auto,*">
  27. <suki:GlassCard IsInteractive="True" Classes="Control" Name="border"
  28. Width="20"
  29. Height="20"
  30. VerticalAlignment="Center"
  31. Classes.PrimaryOpaque="{TemplateBinding IsChecked}"
  32. CornerRadius="6">
  33. <Panel>
  34. <Path Name="checkMark"
  35. Width="9"
  36. Height="9" Opacity="1"
  37. Margin="1,1,0,0"
  38. HorizontalAlignment="Center"
  39. VerticalAlignment="Center"
  40. FlowDirection="LeftToRight"
  41. Data="M 1145.607177734375,430 C1145.607177734375,430 1141.449951171875,435.0772705078125 1141.449951171875,435.0772705078125 1141.449951171875,435.0772705078125 1139.232177734375,433.0999755859375 1139.232177734375,433.0999755859375 1139.232177734375,433.0999755859375 1138,434.5538330078125 1138,434.5538330078125 1138,434.5538330078125 1141.482177734375,438 1141.482177734375,438 1141.482177734375,438 1141.96875,437.9375 1141.96875,437.9375 1141.96875,437.9375 1147,431.34619140625 1147,431.34619140625 1147,431.34619140625 1145.607177734375,430 1145.607177734375,430 z"
  42. Fill="White"
  43. Stretch="Uniform" >
  44. <Path.Transitions>
  45. <Transitions>
  46. <DoubleTransition Property="Opacity" Duration="0:0:0.2"></DoubleTransition>
  47. </Transitions>
  48. </Path.Transitions>
  49. </Path>
  50. <Border Name="IndetBorder" Opacity="0" VerticalAlignment="Center" HorizontalAlignment="Center" Background="White" Height="3" Width="8" CornerRadius="2">
  51. <Border.Transitions>
  52. <Transitions>
  53. <DoubleTransition Property="Opacity" Duration="0:0:0.2"></DoubleTransition>
  54. </Transitions>
  55. </Border.Transitions>
  56. </Border>
  57. </Panel>
  58. </suki:GlassCard>
  59. <ContentPresenter Name="PART_ContentPresenter"
  60. Grid.Column="1"
  61. Margin="{TemplateBinding Padding}"
  62. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  63. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  64. Content="{TemplateBinding Content}"
  65. ContentTemplate="{TemplateBinding ContentTemplate}"
  66. FontSize="{TemplateBinding FontSize}"
  67. IsVisible="{TemplateBinding Content,
  68. Converter={x:Static ObjectConverters.IsNotNull}}"
  69. RecognizesAccessKey="True" />
  70. </Grid>
  71. </ControlTemplate>
  72. </Setter>
  73. </Style>
  74. <Style Selector="CheckBox TextBlock">
  75. <Setter Property="Foreground" Value="{DynamicResource SukiText}" />
  76. </Style>
  77. <Style Selector="CheckBox /template/ Path#checkMark">
  78. <Setter Property="Opacity" Value="0"></Setter>
  79. </Style>
  80. <Style Selector="CheckBox /template/ Rectangle#indeterminateMark">
  81. <Setter Property="Opacity" Value="0"></Setter>
  82. </Style>
  83. <Style Selector="CheckBox:checked /template/ Path#checkMark">
  84. <Setter Property="Opacity" Value="1"></Setter>
  85. </Style>
  86. <Style Selector="CheckBox:indeterminate /template/ Rectangle#indeterminateMark">
  87. <Setter Property="Opacity" Value="0"></Setter>
  88. </Style>
  89. <Style Selector="CheckBox:indeterminate /template/ Border#IndetBorder">
  90. <Setter Property="Opacity" Value="1"></Setter>
  91. </Style>
  92. <Style Selector="CheckBox:disabled /template/ suki|GlassCard#border">
  93. <Setter Property="Opacity" Value="0.7"></Setter>
  94. </Style>
  95. </Styles>