diff --git a/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/NavigationManagerBase.cs b/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/NavigationManagerBase.cs
index a71e238..1b1a670 100644
--- a/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/NavigationManagerBase.cs
+++ b/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/NavigationManagerBase.cs
@@ -1,4 +1,7 @@
-using System.IO;
+using EasyMicroservices.UI.Cores.Interfaces;
+using System;
+using System.Collections.Concurrent;
+using System.IO;
using System.Threading.Tasks;
namespace EasyMicroservices.UI.Cores;
@@ -11,6 +14,10 @@ public abstract class NavigationManagerBase
///
///
public static NavigationManagerBase Current { get; set; }
+ ///
+ ///
+ ///
+ protected ConcurrentDictionary Pages { get; set; } = new ConcurrentDictionary();
///
///
@@ -62,4 +69,13 @@ public abstract class NavigationManagerBase
///
///
public abstract Task OpenBrowser(string url);
+ ///
+ ///
+ ///
+ ///
+ public void RegisterPage(string pageName)
+ where T : IPage, new()
+ {
+ Pages.TryAdd(pageName, typeof(T));
+ }
}
diff --git a/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/Navigations/DefaultNavigationManager.cs b/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/Navigations/DefaultNavigationManager.cs
index 73e4e09..9632840 100644
--- a/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/Navigations/DefaultNavigationManager.cs
+++ b/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/Navigations/DefaultNavigationManager.cs
@@ -11,7 +11,6 @@ public DefaultNavigationManager(INavigation navigation)
_navigation = navigation;
}
- ConcurrentDictionary Pages { get; set; } = new ConcurrentDictionary();
public override Task PopAsync()
{
return _navigation.PopAsync();
@@ -24,8 +23,9 @@ public override Task PushAsync(string pageName, bo
public override async Task PushDataAsync(TData data, string pageName, bool doClear = false)
{
- if (!Pages.TryGetValue(pageName, out IPage findPage))
+ if (!Pages.TryGetValue(pageName, out Type pageTpe))
throw new Exception($"Page {pageName} not found, did you register it?");
+ var findPage = Activator.CreateInstance(pageTpe);
Page page = findPage as Page;
if (page == null)
throw new NotImplementedException($"Page {pageName} is not inherit Page!");