WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit f26caca

Browse files
authored
Merge pull request #202 from reactivemarbles/AddNewControlsToAvaloniaUI
Add new controls, properties, and theming support
2 parents b0f2524 + 4aa06a0 commit f26caca

File tree

13 files changed

+887
-82
lines changed

13 files changed

+887
-82
lines changed

src/CrissCross.Avalonia.UI/Controls/Button/Button.cs

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
/// &lt;ui:Button
16+
/// Appearance="Primary"
17+
/// Content="Avalonia button with icon"
18+
/// Icon="{ui:SymbolIcon Symbol=Fluent24}" /&gt;
19+
/// </code>
20+
/// </example>
1321
public 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);

src/CrissCross.Avalonia.UI/Controls/ComboBox/ComboBox.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,28 @@
22
// ReactiveUI Association Incorporated licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for full license information.
44

5+
using Avalonia;
6+
57
namespace CrissCross.Avalonia.UI.Controls;
68

79
/// <summary>
8-
/// Extended <see cref="Avalonia.Controls.ComboBox"/>.
10+
/// Extended <see cref="Avalonia.Controls.ComboBox"/> with additional properties.
911
/// </summary>
1012
/// <seealso cref="Avalonia.Controls.ComboBox" />
11-
public class ComboBox : global::Avalonia.Controls.ComboBox;
13+
public class ComboBox : global::Avalonia.Controls.ComboBox
14+
{
15+
/// <summary>
16+
/// Property for <see cref="CornerRadius"/>.
17+
/// </summary>
18+
public static readonly StyledProperty<CornerRadius> CornerRadiusProperty =
19+
AvaloniaProperty.Register<ComboBox, CornerRadius>(nameof(CornerRadius));
20+
21+
/// <summary>
22+
/// Gets or sets the corner radius.
23+
/// </summary>
24+
public CornerRadius CornerRadius
25+
{
26+
get => GetValue(CornerRadiusProperty);
27+
set => SetValue(CornerRadiusProperty, value);
28+
}
29+
}

0 commit comments

Comments
 (0)