Add KeyBindingBehavior

This commit is contained in:
TheXamlGuy
2024-04-22 22:30:57 +01:00
parent 5cb7ea538e
commit 7fa80371a4
16 changed files with 77 additions and 32 deletions
+5 -4
View File
@@ -2,16 +2,17 @@
namespace Toolkit.Foundation;
public class NavigateHandler(IComponentScopeProvider provider) :
public class NavigateHandler(ComponentScope scope,
IComponentScopeProvider provider) :
INotificationHandler<Navigate>
{
public async Task Handle(Navigate args,
CancellationToken cancellationToken)
{
if (provider.Get(args.Scope ?? "Default")
is IServiceProvider scope)
if (provider.Get(args.Scope ?? scope.Name)
is ComponentScopeDescriptor descriptor)
{
if (scope.GetService<INavigationScope>() is INavigationScope navigationScope)
if (descriptor?.Services?.GetService<INavigationScope>() is INavigationScope navigationScope)
{
await navigationScope.NavigateAsync(args.Route, args.Sender,
args.Context, args.Navigated, args.Parameters, cancellationToken);