wip
This commit is contained in:
@@ -19,7 +19,7 @@ public class ContentControlHandler :
|
||||
control.Loaded -= HandleLoaded;
|
||||
if (control.DataContext is object content)
|
||||
{
|
||||
if (content is IInitializer initializer)
|
||||
if (content is IInitialization initializer)
|
||||
{
|
||||
await initializer.Initialize();
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public class ContentDialogHandler(IDispatcher dispatcher) :
|
||||
|
||||
// A hack to wait for the dialog to finish loading up to make it appear more responsive
|
||||
await Task.Delay(250);
|
||||
if (content is IInitializer initializer)
|
||||
if (content is IInitialization initializer)
|
||||
{
|
||||
await initializer.Initialize();
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ public class ContentTemplate :
|
||||
{
|
||||
if (observableViewModel.Provider is IServiceProvider provider)
|
||||
{
|
||||
IContentTemplateDescriptorProvider? contentTemplateProvider = provider.GetService<IContentTemplateDescriptorProvider>();
|
||||
INavigationRegion? viewModelContentBinder = provider.GetService<INavigationRegion>();
|
||||
Type itemType = item.GetType();
|
||||
|
||||
if (contentTemplateProvider?.Get(item.GetType().Name) is IContentTemplateDescriptor descriptor)
|
||||
if (provider.GetRequiredKeyedService<IContentTemplateDescriptor>(itemType.Name.Replace("ViewModel", ""))
|
||||
is IContentTemplateDescriptor descriptor)
|
||||
{
|
||||
if (provider.GetRequiredKeyedService(descriptor.TemplateType, descriptor.Key) is Control control)
|
||||
{
|
||||
@@ -28,7 +28,7 @@ public class ContentTemplate :
|
||||
control.Loaded -= HandleLoaded;
|
||||
if (control.DataContext is object content)
|
||||
{
|
||||
if (content is IInitializer initializer)
|
||||
if (content is IInitialization initializer)
|
||||
{
|
||||
await initializer.Initialize();
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class FrameHandler :
|
||||
sender.AddHandler(Frame.NavigatingFromEvent, HandleNavigatingFrom);
|
||||
if (sender.DataContext is object content)
|
||||
{
|
||||
if (content is IInitializer initializer)
|
||||
if (content is IInitialization initializer)
|
||||
{
|
||||
await initializer.Initialize();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Toolkit.Foundation;
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Toolkit.Avalonia;
|
||||
|
||||
@@ -128,11 +129,11 @@ public static class IServiceCollectionExtensions
|
||||
services.AddTransient<IContentTemplate, ContentTemplate>();
|
||||
services.AddTransient<INavigationRegion, NavigationRegion>();
|
||||
|
||||
services.AddNavigateHandler<ClassicDesktopStyleApplicationHandler>();
|
||||
services.AddNavigateHandler<SingleViewApplicationHandler>();
|
||||
services.AddNavigateHandler<ContentControlHandler>();
|
||||
services.AddNavigateHandler<FrameHandler>();
|
||||
services.AddNavigateHandler<ContentDialogHandler>();
|
||||
services.AddHandler<ClassicDesktopStyleApplicationHandler>(nameof(IClassicDesktopStyleApplicationLifetime));
|
||||
services.AddHandler<SingleViewApplicationHandler>(nameof(ISingleViewApplicationLifetime));
|
||||
services.AddHandler<ContentControlHandler>(nameof(ContentControl));
|
||||
services.AddHandler<FrameHandler>(nameof(Frame));
|
||||
services.AddHandler<ContentDialogHandler>(nameof(ContentDialog));
|
||||
|
||||
services.AddScoped<INavigationRegionCollection, NavigationRegionCollection>(provider => new NavigationRegionCollection
|
||||
{
|
||||
@@ -144,15 +145,13 @@ public static class IServiceCollectionExtensions
|
||||
new ProxyServiceCollection<IComponentBuilder>(services =>
|
||||
{
|
||||
services.AddSingleton(provider.GetRequiredService<IDispatcher>());
|
||||
|
||||
services.AddTransient<IContentTemplateDescriptorProvider, ContentTemplateDescriptorProvider>();
|
||||
services.AddTransient<IContentTemplate, ContentTemplate>();
|
||||
|
||||
services.AddTransient<INavigationRegion, NavigationRegion>();
|
||||
|
||||
services.AddNavigateHandler<ContentControlHandler>();
|
||||
services.AddNavigateHandler<FrameHandler>();
|
||||
services.AddNavigateHandler<ContentDialogHandler>();
|
||||
services.AddHandler<ContentControlHandler>(nameof(ContentControl));
|
||||
services.AddHandler<FrameHandler>(nameof(Frame));
|
||||
services.AddHandler<ContentDialogHandler>(nameof(ContentDialog));
|
||||
})));
|
||||
|
||||
return services;
|
||||
|
||||
Reference in New Issue
Block a user