@@ -10,13 +10,21 @@ namespace CrissCross.Avalonia.UI.Controls;
1010/// <summary>
1111/// Inherited from the <see cref="Avalonia.Controls.Button"/>, adding icon support.
1212/// </summary>
13+ /// <example>
14+ /// <code lang="xml">
15+ /// <ui:Button
16+ /// Appearance="Primary"
17+ /// Content="Avalonia button with icon"
18+ /// Icon="{ui:SymbolIcon Symbol=Fluent24}" />
19+ /// </code>
20+ /// </example>
1321public class Button : global ::Avalonia . Controls . Button , IAppearanceControl , IIconControl
1422{
1523 /// <summary>
1624 /// Property for <see cref="Icon"/>.
1725 /// </summary>
18- public static readonly StyledProperty < object > IconProperty = AvaloniaProperty . Register < Button , object > (
19- nameof ( Icon ) ) ;
26+ public static readonly StyledProperty < object ? > IconProperty = AvaloniaProperty . Register < Button , object ? > (
27+ nameof ( Icon ) , coerce : IconElement . Coerce ) ;
2028
2129 /// <summary>
2230 /// Property for <see cref="Appearance"/>.
@@ -27,31 +35,37 @@ public class Button : global::Avalonia.Controls.Button, IAppearanceControl, IIco
2735 /// <summary>
2836 /// Property for <see cref="MouseOverBackground"/>.
2937 /// </summary>
30- public static readonly StyledProperty < IBrush > MouseOverBackgroundProperty = AvaloniaProperty . Register < Button , IBrush > (
38+ public static readonly StyledProperty < IBrush ? > MouseOverBackgroundProperty = AvaloniaProperty . Register < Button , IBrush ? > (
3139 nameof ( MouseOverBackground ) ) ;
3240
3341 /// <summary>
3442 /// Property for <see cref="MouseOverBorderBrush"/>.
3543 /// </summary>
36- public static readonly StyledProperty < IBrush > MouseOverBorderBrushProperty = AvaloniaProperty . Register < Button , IBrush > (
44+ public static readonly StyledProperty < IBrush ? > MouseOverBorderBrushProperty = AvaloniaProperty . Register < Button , IBrush ? > (
3745 nameof ( MouseOverBorderBrush ) ) ;
3846
47+ /// <summary>
48+ /// Property for <see cref="MouseOverForeground"/>.
49+ /// </summary>
50+ public static readonly StyledProperty < IBrush ? > MouseOverForegroundProperty = AvaloniaProperty . Register < Button , IBrush ? > (
51+ nameof ( MouseOverForeground ) ) ;
52+
3953 /// <summary>
4054 /// Property for <see cref="PressedForeground"/>.
4155 /// </summary>
42- public static readonly StyledProperty < IBrush > PressedForegroundProperty = AvaloniaProperty . Register < Button , IBrush > (
56+ public static readonly StyledProperty < IBrush ? > PressedForegroundProperty = AvaloniaProperty . Register < Button , IBrush ? > (
4357 nameof ( PressedForeground ) ) ;
4458
4559 /// <summary>
4660 /// Property for <see cref="PressedBackground"/>.
4761 /// </summary>
48- public static readonly StyledProperty < IBrush > PressedBackgroundProperty = AvaloniaProperty . Register < Button , IBrush > (
62+ public static readonly StyledProperty < IBrush ? > PressedBackgroundProperty = AvaloniaProperty . Register < Button , IBrush ? > (
4963 nameof ( PressedBackground ) ) ;
5064
5165 /// <summary>
5266 /// Property for <see cref="PressedBorderBrush"/>.
5367 /// </summary>
54- public static readonly StyledProperty < IBrush > PressedBorderBrushProperty = AvaloniaProperty . Register < Button , IBrush > (
68+ public static readonly StyledProperty < IBrush ? > PressedBorderBrushProperty = AvaloniaProperty . Register < Button , IBrush ? > (
5569 nameof ( PressedBorderBrush ) ) ;
5670
5771 /// <summary>
@@ -61,7 +75,7 @@ public class Button : global::Avalonia.Controls.Button, IAppearanceControl, IIco
6175 nameof ( CornerRadius ) ) ;
6276
6377 /// <summary>
64- /// Gets or sets displayed icon .
78+ /// Gets or sets displayed <see cref="IconElement"/> .
6579 /// </summary>
6680 public object ? Icon
6781 {
@@ -79,7 +93,7 @@ public ControlAppearance Appearance
7993 /// <summary>
8094 /// Gets or sets background brush when the user interacts with an element with a pointing device.
8195 /// </summary>
82- public IBrush MouseOverBackground
96+ public IBrush ? MouseOverBackground
8397 {
8498 get => GetValue ( MouseOverBackgroundProperty ) ;
8599 set => SetValue ( MouseOverBackgroundProperty , value ) ;
@@ -88,16 +102,25 @@ public IBrush MouseOverBackground
88102 /// <summary>
89103 /// Gets or sets border brush when the user interacts with an element with a pointing device.
90104 /// </summary>
91- public IBrush MouseOverBorderBrush
105+ public IBrush ? MouseOverBorderBrush
92106 {
93107 get => GetValue ( MouseOverBorderBrushProperty ) ;
94108 set => SetValue ( MouseOverBorderBrushProperty , value ) ;
95109 }
96110
111+ /// <summary>
112+ /// Gets or sets foreground brush when the user interacts with an element with a pointing device.
113+ /// </summary>
114+ public IBrush ? MouseOverForeground
115+ {
116+ get => GetValue ( MouseOverForegroundProperty ) ;
117+ set => SetValue ( MouseOverForegroundProperty , value ) ;
118+ }
119+
97120 /// <summary>
98121 /// Gets or sets foreground when pressed.
99122 /// </summary>
100- public IBrush PressedForeground
123+ public IBrush ? PressedForeground
101124 {
102125 get => GetValue ( PressedForegroundProperty ) ;
103126 set => SetValue ( PressedForegroundProperty , value ) ;
@@ -106,7 +129,7 @@ public IBrush PressedForeground
106129 /// <summary>
107130 /// Gets or sets background brush when the user clicks the button.
108131 /// </summary>
109- public IBrush PressedBackground
132+ public IBrush ? PressedBackground
110133 {
111134 get => GetValue ( PressedBackgroundProperty ) ;
112135 set => SetValue ( PressedBackgroundProperty , value ) ;
@@ -115,7 +138,7 @@ public IBrush PressedBackground
115138 /// <summary>
116139 /// Gets or sets border brush when the user clicks the button.
117140 /// </summary>
118- public IBrush PressedBorderBrush
141+ public IBrush ? PressedBorderBrush
119142 {
120143 get => GetValue ( PressedBorderBrushProperty ) ;
121144 set => SetValue ( PressedBorderBrushProperty , value ) ;
0 commit comments