feat: Breadcrumb and its item may support CommandParameter/Binding

This commit is contained in:
Gehongyan
2024-08-21 13:47:29 +08:00
parent 0c17aec5c3
commit 591d53cbd3
2 changed files with 25 additions and 1 deletions

View File

@@ -35,6 +35,17 @@ public class Breadcrumb: ItemsControl
set => SetValue(CommandBindingProperty, value);
}
public static readonly StyledProperty<IBinding?> CommandParameterBindingProperty = AvaloniaProperty.Register<Breadcrumb, IBinding?>(
nameof(CommandParameterBinding));
[AssignBinding]
[InheritDataTypeFromItems(nameof(ItemsSource))]
public IBinding? CommandParameterBinding
{
get => GetValue(CommandParameterBindingProperty);
set => SetValue(CommandParameterBindingProperty, value);
}
public static readonly StyledProperty<object?> SeparatorProperty = AvaloniaProperty.Register<Breadcrumb, object?>(
nameof(Separator));
@@ -112,6 +123,10 @@ public class Breadcrumb: ItemsControl
{
breadcrumbItem[!BreadcrumbItem.CommandProperty] = CommandBinding;
}
if (!breadcrumbItem.IsSet(BreadcrumbItem.CommandParameterProperty) && CommandParameterBinding != null)
{
breadcrumbItem[!BreadcrumbItem.CommandParameterProperty] = CommandParameterBinding;
}
if (!breadcrumbItem.IsSet(BreadcrumbItem.IconTemplateProperty) && IconTemplate != null)
{
breadcrumbItem.IconTemplate = IconTemplate;