Merge pull request #358 from gehongyan/breadcrubmitem-commandparameter
feat: Breadcrumb and its item may support CommandParameter/Binding
This commit is contained in:
@@ -35,6 +35,17 @@ public class Breadcrumb: ItemsControl
|
|||||||
set => SetValue(CommandBindingProperty, value);
|
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?>(
|
public static readonly StyledProperty<object?> SeparatorProperty = AvaloniaProperty.Register<Breadcrumb, object?>(
|
||||||
nameof(Separator));
|
nameof(Separator));
|
||||||
|
|
||||||
@@ -112,6 +123,10 @@ public class Breadcrumb: ItemsControl
|
|||||||
{
|
{
|
||||||
breadcrumbItem[!BreadcrumbItem.CommandProperty] = CommandBinding;
|
breadcrumbItem[!BreadcrumbItem.CommandProperty] = CommandBinding;
|
||||||
}
|
}
|
||||||
|
if (!breadcrumbItem.IsSet(BreadcrumbItem.CommandParameterProperty) && CommandParameterBinding != null)
|
||||||
|
{
|
||||||
|
breadcrumbItem[!BreadcrumbItem.CommandParameterProperty] = CommandParameterBinding;
|
||||||
|
}
|
||||||
if (!breadcrumbItem.IsSet(BreadcrumbItem.IconTemplateProperty) && IconTemplate != null)
|
if (!breadcrumbItem.IsSet(BreadcrumbItem.IconTemplateProperty) && IconTemplate != null)
|
||||||
{
|
{
|
||||||
breadcrumbItem.IconTemplate = IconTemplate;
|
breadcrumbItem.IconTemplate = IconTemplate;
|
||||||
|
|||||||
@@ -39,6 +39,15 @@ public class BreadcrumbItem: ContentControl
|
|||||||
set => SetValue(CommandProperty, value);
|
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?>(
|
public static readonly StyledProperty<IDataTemplate?> IconTemplateProperty = AvaloniaProperty.Register<BreadcrumbItem, IDataTemplate?>(
|
||||||
nameof(IconTemplate));
|
nameof(IconTemplate));
|
||||||
|
|
||||||
@@ -62,7 +71,7 @@ public class BreadcrumbItem: ContentControl
|
|||||||
base.OnPointerPressed(e);
|
base.OnPointerPressed(e);
|
||||||
if (!IsReadOnly)
|
if (!IsReadOnly)
|
||||||
{
|
{
|
||||||
Command?.Execute(null);
|
Command?.Execute(CommandParameter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user