diff --git a/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/Navigations/NavigationManagerBase.cs b/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/Navigations/NavigationManagerBase.cs
index 2940e3c..ff171ad 100644
--- a/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/Navigations/NavigationManagerBase.cs
+++ b/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/Navigations/NavigationManagerBase.cs
@@ -17,7 +17,7 @@ public abstract class NavigationManagerBase
///
///
///
- protected ConcurrentDictionary Pages { get; set; } = new ConcurrentDictionary();
+ protected ConcurrentDictionary> Pages { get; set; } = new ConcurrentDictionary>();
///
///
@@ -76,6 +76,6 @@ public abstract class NavigationManagerBase
public void RegisterPage(string pageName)
where T : IPage, new()
{
- Pages.TryAdd(pageName, typeof(T));
+ Pages.TryAdd(pageName, () => new T());
}
}
diff --git a/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/Navigations/DefaultNavigationManager.cs b/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/Navigations/DefaultNavigationManager.cs
index 8cfa7d0..4ab4558 100644
--- a/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/Navigations/DefaultNavigationManager.cs
+++ b/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/Navigations/DefaultNavigationManager.cs
@@ -1,6 +1,7 @@
using EasyMicroservices.UI.Cores;
using EasyMicroservices.UI.Cores.Interfaces;
using EasyMicroservices.UI.Cores.Navigations;
+using EasyMicroservices.UI.MauiComponents.Design.Pages;
namespace EasyMicroservices.UI.MauiComponents.Navigations;
public class DefaultNavigationManager : NavigationManagerBase
@@ -23,9 +24,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 Type pageTpe))
+ if (!Pages.TryGetValue(pageName, out Func pageCreator))
throw new Exception($"Page {pageName} not found, did you register it?");
- var findPage = Activator.CreateInstance(pageTpe);
+ var findPage = pageCreator();
ContentPage page = findPage as ContentPage;
if (page == null)
throw new NotImplementedException($"Page {pageName} is not inherit Page!");
@@ -86,4 +87,20 @@ public override Task OpenBrowser(string url)
{
return Browser.OpenAsync(url, BrowserLaunchMode.SystemPreferred);
}
+
+ ///
+ ///
+ ///
+ ///
+ public void RegisterContentPage(string pageName)
+ where TView : ContentView, new()
+ {
+ Pages.TryAdd(pageName, () =>
+ {
+ return new EasyContentPage()
+ {
+ Content = new TView()
+ };
+ });
+ }
}
\ No newline at end of file