Fixes
This commit is contained in:
@@ -38,7 +38,7 @@ public class DefaultHostBuilder :
|
|||||||
|
|
||||||
services.AddTransient<IContentFactory, ContentFactory>();
|
services.AddTransient<IContentFactory, ContentFactory>();
|
||||||
|
|
||||||
services.AddScoped<INavigationRegionCollection, NavigationRegionCollection>();
|
services.AddSingleton<INavigationRegionCollection, NavigationRegionCollection>();
|
||||||
services.AddTransient<INavigationRegionProvider, NavigationRegionProvider>();
|
services.AddTransient<INavigationRegionProvider, NavigationRegionProvider>();
|
||||||
|
|
||||||
services.AddScoped<INavigation, Navigation>();
|
services.AddScoped<INavigation, Navigation>();
|
||||||
@@ -52,8 +52,8 @@ public class DefaultHostBuilder :
|
|||||||
services.AddTransient<IComponentFactory, ComponentFactory>();
|
services.AddTransient<IComponentFactory, ComponentFactory>();
|
||||||
services.AddTransient<IComponentScopeProvider, ComponentScopeProvider>();
|
services.AddTransient<IComponentScopeProvider, ComponentScopeProvider>();
|
||||||
|
|
||||||
services.AddHandler<NavigateEventArgs, NavigateHandler>();
|
services.AddHandlerScoped<NavigateEventArgs, NavigateHandler>();
|
||||||
services.AddHandler<NavigateBackEventArgs, NavigateBackHandler>();
|
services.AddHandlerScoped<NavigateBackEventArgs, NavigateBackHandler>();
|
||||||
|
|
||||||
services.AddInitialization<ComponentInitializer>();
|
services.AddInitialization<ComponentInitializer>();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public class NavigateHandler(NamedComponent scope,
|
public class NavigateHandler(NamedComponent named,
|
||||||
IComponentScopeProvider componentScopeProvider) :
|
IComponentScopeProvider componentScopeProvider) :
|
||||||
IHandler<NavigateEventArgs>
|
IHandler<NavigateEventArgs>
|
||||||
{
|
{
|
||||||
@@ -28,7 +28,7 @@ public class NavigateHandler(NamedComponent scope,
|
|||||||
|
|
||||||
if (navigation is null)
|
if (navigation is null)
|
||||||
{
|
{
|
||||||
ComponentScopeDescriptor? descriptor = componentScopeProvider.Get(args.Scope ?? scope.Key);
|
ComponentScopeDescriptor? descriptor = componentScopeProvider.Get(args.Scope ?? named.Key);
|
||||||
navigation = descriptor?.Services?.GetRequiredService<INavigation>();
|
navigation = descriptor?.Services?.GetRequiredService<INavigation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class Navigation(IServiceProvider provider,
|
|||||||
{
|
{
|
||||||
currentSegmentIndex++;
|
currentSegmentIndex++;
|
||||||
|
|
||||||
if (provider.GetKeyedService<IContentTemplateDescriptor>(segment)
|
if (provider.GetRequiredKeyedService<IContentTemplateDescriptor>(segment)
|
||||||
is IContentTemplateDescriptor descriptor)
|
is IContentTemplateDescriptor descriptor)
|
||||||
{
|
{
|
||||||
Dictionary<string, object>? arguments = parameters?.ToDictionary(x => x.Key, x => x.Value, StringComparer.InvariantCultureIgnoreCase) ?? [];
|
Dictionary<string, object>? arguments = parameters?.ToDictionary(x => x.Key, x => x.Value, StringComparer.InvariantCultureIgnoreCase) ?? [];
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace Toolkit.UI.WinUI;
|
|
||||||
|
|
||||||
public class ItemInvokedEventArgs : EventArgs;
|
|
||||||
@@ -75,7 +75,7 @@ public class NavigateAction :
|
|||||||
ImmutableDictionary<string, object>.Empty;
|
ImmutableDictionary<string, object>.Empty;
|
||||||
|
|
||||||
observableViewModel.Messenger.Send(new NavigateEventArgs(Route, Region.Equals(this) ? content : Region, Scope ?? null,
|
observableViewModel.Messenger.Send(new NavigateEventArgs(Route, Region.Equals(this) ? content : Region, Scope ?? null,
|
||||||
content, Navigated, parameters));
|
content.DataContext, Navigated, parameters));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,14 +10,10 @@ public class ContentControlHandler :
|
|||||||
public void Handle(NavigateTemplateEventArgs args)
|
public void Handle(NavigateTemplateEventArgs args)
|
||||||
{
|
{
|
||||||
if (args.Region is not ContentControl contentControl)
|
if (args.Region is not ContentControl contentControl)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (args.Template is not Control control)
|
if (args.Template is not Control control)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
void HandleLoaded(object? sender, RoutedEventArgs args)
|
void HandleLoaded(object? sender, RoutedEventArgs args)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ public static class IServiceCollectionExtensions
|
|||||||
services.AddTransient<IContentTemplate, ContentTemplate>();
|
services.AddTransient<IContentTemplate, ContentTemplate>();
|
||||||
services.AddTransient<INavigationRegion, NavigationRegion>();
|
services.AddTransient<INavigationRegion, NavigationRegion>();
|
||||||
|
|
||||||
services.AddHandler<NavigateTemplateEventArgs, ContentControlHandler>(nameof(ContentControl));
|
services.AddHandlerScoped<NavigateTemplateEventArgs, ContentControlHandler>(nameof(ContentControl));
|
||||||
services.AddHandler<NavigateTemplateEventArgs, ContentDialogHandler>(nameof(ContentDialog));
|
services.AddHandlerScoped<NavigateTemplateEventArgs, ContentDialogHandler>(nameof(ContentDialog));
|
||||||
|
|
||||||
services.AddTransient((Func<IServiceProvider, IProxyServiceCollection<IComponentBuilder>>)(provider =>
|
services.AddTransient((Func<IServiceProvider, IProxyServiceCollection<IComponentBuilder>>)(provider =>
|
||||||
new ProxyServiceCollection<IComponentBuilder>(services =>
|
new ProxyServiceCollection<IComponentBuilder>(services =>
|
||||||
|
|||||||
Reference in New Issue
Block a user