feat: introduce Small class and IsReadOnly property.
This commit is contained in:
15
src/Ursa/Controls/BackTop/BackTop.cs
Normal file
15
src/Ursa/Controls/BackTop/BackTop.cs
Normal 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);
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user