Add contextual commands

This commit is contained in:
TheXamlGuy
2024-05-19 14:18:08 +01:00
parent 6718675f12
commit e733728022
11 changed files with 60 additions and 71 deletions
+22 -16
View File
@@ -2,24 +2,30 @@
namespace Bitvault;
public partial class ItemCommandHeaderViewModel : ObservableCollection
public partial class ItemCommandHeaderViewModel(IServiceProvider provider,
IServiceFactory factory,
IMediator mediator,
IPublisher publisher,
ISubscription subscriber,
IDisposer disposer,
IContentTemplate template) :
ObservableCollection(provider, factory, mediator, publisher, subscriber, disposer),
INotificationHandler<NotifyEventArgs<CommandCollection>>
{
public ItemCommandHeaderViewModel(IServiceProvider provider,
IServiceFactory factory,
IMediator mediator,
IPublisher publisher,
ISubscription subscriber,
IDisposer disposer,
IContentTemplate template) : base(provider, factory, mediator, publisher, subscriber, disposer)
public IContentTemplate Template { get; set; } = template;
public Task Handle(NotifyEventArgs<CommandCollection> args)
{
Add<ConfirmItemActionViewModel>();
Add<DismissItemActionViewModel>();
Add<EditItemActionViewModel>();
Add<DeleteItemActionViewModel>();
Add<ArchiveItemActionViewModel>();
Clear();
Template = template;
if (args.Value is CommandCollection commandCollection)
{
foreach (IDisposable command in commandCollection)
{
Add(command);
}
}
return Task.CompletedTask;
}
public IContentTemplate Template { get; set; }
}