Skip to content

Commit

Permalink
chore: add avalonia RadioButton demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
NaBian committed Dec 1, 2024
1 parent 2f0b397 commit 4713903
Show file tree
Hide file tree
Showing 13 changed files with 792 additions and 21 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace HandyControlDemo.UserControl;

public partial class RadioButtonDemoCtl : Avalonia.Controls.UserControl
{
public RadioButtonDemoCtl()
{
InitializeComponent();
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Avalonia;
using Avalonia.Media;

namespace HandyControl.Controls;

public class VisualElement
{
public static readonly AttachedProperty<IBrush> HighlightBrushProperty =
AvaloniaProperty.RegisterAttached<VisualElement, AvaloniaObject, IBrush>("HighlightBrush", inherits: true);

public static void SetHighlightBrush(AvaloniaObject element, IBrush value) =>
element.SetValue(HighlightBrushProperty, value);

public static IBrush GetHighlightBrush(AvaloniaObject element) => element.GetValue(HighlightBrushProperty);

public static readonly AttachedProperty<IBrush> HighlightBackgroundProperty =
AvaloniaProperty.RegisterAttached<VisualElement, AvaloniaObject, IBrush>("HighlightBackground", inherits: true);

public static void SetHighlightBackground(AvaloniaObject element, IBrush value) =>
element.SetValue(HighlightBackgroundProperty, value);

public static IBrush GetHighlightBackground(AvaloniaObject element) =>
element.GetValue(HighlightBackgroundProperty);

public static readonly AttachedProperty<IBrush> HighlightBorderBrushProperty =
AvaloniaProperty.RegisterAttached<VisualElement, AvaloniaObject, IBrush>("HighlightBorderBrush",
inherits: true);

public static void SetHighlightBorderBrush(AvaloniaObject element, IBrush value) =>
element.SetValue(HighlightBorderBrushProperty, value);

public static IBrush GetHighlightBorderBrush(AvaloniaObject element) =>
element.GetValue(HighlightBorderBrushProperty);

public static readonly AttachedProperty<IBrush> HighlightForegroundProperty =
AvaloniaProperty.RegisterAttached<VisualElement, AvaloniaObject, IBrush>("HighlightForeground", inherits: true);

public static void SetHighlightForeground(AvaloniaObject element, IBrush value) =>
element.SetValue(HighlightForegroundProperty, value);

public static IBrush GetHighlightForeground(AvaloniaObject element) =>
element.GetValue(HighlightForegroundProperty);

public static readonly AttachedProperty<string> TextProperty =
AvaloniaProperty.RegisterAttached<VisualElement, AvaloniaObject, string>("Text");

public static void SetText(AvaloniaObject element, string value) => element.SetValue(TextProperty, value);

public static string GetText(AvaloniaObject element) => element.GetValue(TextProperty);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converter="clr-namespace:HandyControl.Tools.Converter">

<converter:Boolean2BooleanReConverter x:Key="Boolean2BooleanReConverter" />
<converter:BorderClipConverter x:Key="BorderClipConverter" />
<converter:BorderCircularConverter x:Key="BorderCircularConverter"/>
<converter:BorderCircularConverter x:Key="BorderCircularConverter" />
<converter:GeometrySpacingConverter x:Key="GeometrySpacingConverter" />

</ResourceDictionary>
4 changes: 2 additions & 2 deletions src/Avalonia/HandyControl_Avalonia/Themes/Styles/Button.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Value="{Binding $self.(hc:BorderElement.CornerRadius)}" />
<Setter Property="Template">
<ControlTemplate>
<Grid>
<Panel>
<Border Background="{TemplateBinding Background}"
CornerRadius="{TemplateBinding CornerRadius}" />
<Border BorderThickness="{TemplateBinding BorderThickness}"
Expand All @@ -53,7 +53,7 @@
Margin="{Binding Path=(hc:IconElement.Geometry), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource GeometrySpacingConverter}, ConverterParameter='6,0,0,0'}" />
</StackPanel>
</Border>
</Grid>
</Panel>
</ControlTemplate>
</Setter>

Expand Down
Loading

0 comments on commit 4713903

Please sign in to comment.