feat: implement command, fix icon foreground in light mode.
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
<u:Breadcrumb
|
||||
DisplayMemberBinding="{Binding Section}"
|
||||
IconBinding="{Binding Icon}"
|
||||
CommandBinding="{Binding Command}"
|
||||
ItemsSource="{Binding Items1}">
|
||||
<u:Breadcrumb.IconTemplate>
|
||||
<DataTemplate DataType="x:String">
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Input;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Ursa.Controls;
|
||||
|
||||
namespace Ursa.Demo.ViewModels;
|
||||
|
||||
@@ -24,4 +27,14 @@ public class BreadcrumbDemoItem: ObservableObject
|
||||
{
|
||||
public string Section { get; set; }
|
||||
public string Icon { get; set; }
|
||||
|
||||
public ICommand Command { get; set; }
|
||||
|
||||
public BreadcrumbDemoItem()
|
||||
{
|
||||
Command = new RelayCommand(() =>
|
||||
{
|
||||
MessageBox.ShowOverlayAsync(Section);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@
|
||||
VerticalAlignment="Center"
|
||||
Content="{TemplateBinding Icon}"
|
||||
ContentTemplate="{TemplateBinding IconTemplate}"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
Foreground="{DynamicResource SemiColorText2}"
|
||||
IsVisible="{TemplateBinding Icon,
|
||||
Converter={x:Static ObjectConverters.IsNotNull}}" />
|
||||
<ContentPresenter
|
||||
|
||||
@@ -3,6 +3,7 @@ using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Metadata;
|
||||
using Avalonia.Controls.Templates;
|
||||
using Avalonia.Input;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
@@ -47,8 +48,9 @@ public class BreadcrumbItem: ContentControl
|
||||
set => SetValue(IconTemplateProperty, value);
|
||||
}
|
||||
|
||||
static BreadcrumbItem()
|
||||
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
||||
{
|
||||
|
||||
base.OnPointerPressed(e);
|
||||
Command?.Execute(null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user