feat: move readonly to item.

This commit is contained in:
rabbitism
2024-03-05 17:53:16 +08:00
parent fdc6b2e156
commit 8ac608505b
5 changed files with 25 additions and 71 deletions

View File

@@ -56,15 +56,6 @@ 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

@@ -49,11 +49,19 @@ public class BreadcrumbItem: ContentControl
set => SetValue(IconTemplateProperty, value);
}
public static readonly StyledProperty<bool> IsReadOnlyProperty = AvaloniaProperty.Register<BreadcrumbItem, bool>(
nameof(IsReadOnly));
public bool IsReadOnly
{
get => GetValue(IsReadOnlyProperty);
set => SetValue(IsReadOnlyProperty, value);
}
protected override void OnPointerPressed(PointerPressedEventArgs e)
{
base.OnPointerPressed(e);
var parent = this.FindLogicalAncestorOfType<Breadcrumb>();
if (parent?.IsReadOnly != true)
if (!IsReadOnly)
{
Command?.Execute(null);
}