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

@@ -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);
}
}
}