feat: implement semi style.
This commit is contained in:
@@ -56,15 +56,6 @@ public class Breadcrumb: ItemsControl
|
||||
get => GetValue(IconTemplateProperty);
|
||||
set => SetValue(IconTemplateProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<int> MaxItemCountProperty = AvaloniaProperty.Register<Breadcrumb, int>(
|
||||
nameof(MaxItemCount), defaultValue: 4);
|
||||
|
||||
public int MaxItemCount
|
||||
{
|
||||
get => GetValue(MaxItemCountProperty);
|
||||
set => SetValue(MaxItemCountProperty, value);
|
||||
}
|
||||
|
||||
static Breadcrumb()
|
||||
{
|
||||
@@ -84,7 +75,6 @@ public class Breadcrumb: ItemsControl
|
||||
protected override void PrepareContainerForItemOverride(Control container, object? item, int index)
|
||||
{
|
||||
// base.PrepareContainerForItemOverride(container, item, index);
|
||||
if (container == item) return;
|
||||
if (container is not BreadcrumbItem breadcrumbItem) return;
|
||||
if (!breadcrumbItem.IsSet(BreadcrumbItem.SeparatorProperty))
|
||||
{
|
||||
@@ -98,6 +88,10 @@ public class Breadcrumb: ItemsControl
|
||||
breadcrumbItem.Separator = b;
|
||||
});
|
||||
}
|
||||
|
||||
PseudolassesExtensions.Set(container.Classes, BreadcrumbItem.PC_Last, index == ItemCount - 1);
|
||||
|
||||
if (container == item) return;
|
||||
if(!breadcrumbItem.IsSet(ContentControl.ContentProperty))
|
||||
{
|
||||
breadcrumbItem.SetCurrentValue(ContentControl.ContentProperty, item);
|
||||
@@ -106,6 +100,10 @@ public class Breadcrumb: ItemsControl
|
||||
breadcrumbItem[!ContentControl.ContentProperty] = DisplayMemberBinding;
|
||||
}
|
||||
}
|
||||
if (!breadcrumbItem.IsSet(ContentControl.ContentTemplateProperty) && this.ItemTemplate != null)
|
||||
{
|
||||
breadcrumbItem.SetCurrentValue(ContentControl.ContentTemplateProperty, this.ItemTemplate);
|
||||
}
|
||||
if (!breadcrumbItem.IsSet(BreadcrumbItem.IconProperty) && IconBinding != null)
|
||||
{
|
||||
breadcrumbItem[!BreadcrumbItem.IconProperty] = IconBinding;
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
using System.Windows.Input;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Metadata;
|
||||
using Avalonia.Controls.Templates;
|
||||
|
||||
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));
|
||||
|
||||
Reference in New Issue
Block a user