77 lines
2.2 KiB
C#
77 lines
2.2 KiB
C#
using System.Windows.Input;
|
|
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Controls.Metadata;
|
|
using Avalonia.Controls.Templates;
|
|
using Avalonia.Input;
|
|
|
|
namespace Ursa.Controls;
|
|
|
|
[PseudoClasses(PC_Last)]
|
|
public class BreadcrumbItem: ContentControl
|
|
{
|
|
public const string PC_Last = ":last";
|
|
public static readonly StyledProperty<object?> SeparatorProperty =
|
|
AvaloniaProperty.Register<BreadcrumbItem, object?>(
|
|
nameof(Separator));
|
|
|
|
public object? Separator
|
|
{
|
|
get => GetValue(SeparatorProperty);
|
|
set => SetValue(SeparatorProperty, value);
|
|
}
|
|
|
|
public static readonly StyledProperty<object?> IconProperty = AvaloniaProperty.Register<BreadcrumbItem, object?>(
|
|
nameof(Icon));
|
|
|
|
public object? Icon
|
|
{
|
|
get => GetValue(IconProperty);
|
|
set => SetValue(IconProperty, value);
|
|
}
|
|
|
|
public static readonly StyledProperty<ICommand?> CommandProperty = AvaloniaProperty.Register<BreadcrumbItem, ICommand?>(
|
|
nameof(Command));
|
|
|
|
public ICommand? Command
|
|
{
|
|
get => GetValue(CommandProperty);
|
|
set => SetValue(CommandProperty, value);
|
|
}
|
|
|
|
public static readonly StyledProperty<object?> CommandParameterProperty = AvaloniaProperty.Register<BreadcrumbItem, object?>(
|
|
nameof(CommandParameter));
|
|
|
|
public object? CommandParameter
|
|
{
|
|
get => GetValue(CommandParameterProperty);
|
|
set => SetValue(CommandParameterProperty, value);
|
|
}
|
|
|
|
public static readonly StyledProperty<IDataTemplate?> IconTemplateProperty = AvaloniaProperty.Register<BreadcrumbItem, IDataTemplate?>(
|
|
nameof(IconTemplate));
|
|
|
|
public IDataTemplate? IconTemplate
|
|
{
|
|
get => GetValue(IconTemplateProperty);
|
|
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);
|
|
if (!IsReadOnly)
|
|
{
|
|
Command?.Execute(CommandParameter);
|
|
}
|
|
}
|
|
} |