Button.axaml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  2. <Design.PreviewWith>
  3. <Button />
  4. </Design.PreviewWith>
  5. <ControlTheme x:Key="{x:Type Button}" TargetType="Button">
  6. <Setter Property="Button.Template">
  7. <ControlTemplate TargetType="Button">
  8. <ContentPresenter
  9. Name="PART_ContentPresenter"
  10. Padding="{TemplateBinding Padding}"
  11. HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
  12. VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
  13. Background="{TemplateBinding Background}"
  14. BorderBrush="{TemplateBinding BorderBrush}"
  15. BorderThickness="{TemplateBinding BorderThickness}"
  16. Content="{TemplateBinding Content}"
  17. ContentTemplate="{TemplateBinding ContentTemplate}"
  18. CornerRadius="{TemplateBinding CornerRadius}"
  19. RecognizesAccessKey="True"
  20. TextElement.Foreground="{TemplateBinding Foreground}" />
  21. </ControlTemplate>
  22. </Setter>
  23. <Style Selector="^.hover:pointerover /template/ ContentPresenter#PART_ContentPresenter">
  24. <Style.Animations>
  25. <Animation IterationCount="1" Duration=".35">
  26. <KeyFrame>
  27. <Setter Property="Background">
  28. <SolidColorBrush Color="{StaticResource SecondaryBackgroundColor}" />
  29. </Setter>
  30. </KeyFrame>
  31. <KeyFrame Cue="1">
  32. <Setter Property="Background">
  33. <SolidColorBrush Color="{DynamicResource AccentColor}" />
  34. </Setter>
  35. </KeyFrame>
  36. </Animation>
  37. </Style.Animations>
  38. <Setter Property="Background" Value="{DynamicResource AccentColor}" />
  39. </Style>
  40. <Style Selector="^.altHover:pointerover /template/ ContentPresenter#PART_ContentPresenter">
  41. <Style.Animations>
  42. <Animation IterationCount="1" Duration=".35">
  43. <KeyFrame>
  44. <Setter Property="Background">
  45. <SolidColorBrush Color="{StaticResource SecondaryBackgroundColor}" />
  46. </Setter>
  47. </KeyFrame>
  48. <KeyFrame Cue="1">
  49. <Setter Property="Background">
  50. <SolidColorBrush Color="{StaticResource BackgroundHoverColor}" />
  51. </Setter>
  52. </KeyFrame>
  53. </Animation>
  54. </Style.Animations>
  55. <Setter Property="Background" Value="{StaticResource BackgroundHoverColor}" />
  56. </Style>
  57. <Style Selector="^.alphaHover:pointerover /template/ ContentPresenter#PART_ContentPresenter">
  58. <Style.Animations>
  59. <Animation IterationCount="1" Duration=".35">
  60. <KeyFrame>
  61. <Setter Property="Background">
  62. <SolidColorBrush Color="Transparent" />
  63. </Setter>
  64. </KeyFrame>
  65. <KeyFrame Cue="1">
  66. <Setter Property="Background">
  67. <SolidColorBrush Color="{StaticResource AltBackgroundHoverColor}" />
  68. </Setter>
  69. </KeyFrame>
  70. </Animation>
  71. </Style.Animations>
  72. <Setter Property="Background" Value="{StaticResource AltBackgroundHoverColor}" />
  73. </Style>
  74. <Style Selector="^.hover:pressed /template/ ContentPresenter#PART_ContentPresenter">
  75. <Setter Property="Background" Value="{DynamicResource SecondaryAccentColor}" />
  76. </Style>
  77. <Style Selector="^.alphaHover:pressed /template/ ContentPresenter#PART_ContentPresenter">
  78. <Setter Property="Background" Value="{DynamicResource SecondaryAccentColor}" />
  79. </Style>
  80. <Style Selector="^:disabled">
  81. <Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}" />
  82. </Style>
  83. </ControlTheme>
  84. </ResourceDictionary>