feat: introduce Small class and IsReadOnly property.

This commit is contained in:
rabbitism
2024-03-05 16:47:33 +08:00
parent 2790066333
commit fdc6b2e156
7 changed files with 138 additions and 17 deletions

View File

@@ -0,0 +1,15 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Media;
namespace Ursa.Controls.BackTop;
public class BackTop: Control
{
public static readonly AttachedProperty<bool> AttachProperty =
AvaloniaProperty.RegisterAttached<BackTop, Control, bool>("Attach");
public static void SetAttach(Control obj, bool value) => obj.SetValue(AttachProperty, value);
public static bool GetAttach(Control obj) => obj.GetValue(AttachProperty);
}

View File

@@ -56,6 +56,15 @@ public class Breadcrumb: ItemsControl
get => GetValue(IconTemplateProperty);
set => SetValue(IconTemplateProperty, value);
}
public static readonly StyledProperty<bool> IsReadOnlyProperty = AvaloniaProperty.Register<Breadcrumb, bool>(
nameof(IsReadOnly));
public bool IsReadOnly
{
get => GetValue(IsReadOnlyProperty);
set => SetValue(IsReadOnlyProperty, value);
}
static Breadcrumb()
{

View File

@@ -4,6 +4,7 @@ using Avalonia.Controls;
using Avalonia.Controls.Metadata;
using Avalonia.Controls.Templates;
using Avalonia.Input;
using Avalonia.LogicalTree;
namespace Ursa.Controls;
@@ -51,6 +52,10 @@ public class BreadcrumbItem: ContentControl
protected override void OnPointerPressed(PointerPressedEventArgs e)
{
base.OnPointerPressed(e);
Command?.Execute(null);
var parent = this.FindLogicalAncestorOfType<Breadcrumb>();
if (parent?.IsReadOnly != true)
{
Command?.Execute(null);
}
}
}