Commit 7bc1dcf7 authored by 潘栩锋's avatar 潘栩锋 🚴

添加 全局 Page页面队列。 因为解决不了Page页面不会释放问题

parent f551821f
......@@ -26,6 +26,25 @@ namespace MultiLayout
}
}
/// <summary>
/// 全局page, 资源永远不释放
/// </summary>
public static Dictionary<string,Page> AllPages = new Dictionary<string,Page>();
public static Page GetPage(string pageName, Func<Page> createPageHandler)
{
Page p;
if (AllPages.ContainsKey(pageName))
{
p = AllPages[pageName];
}
else {
p = createPageHandler();
AllPages.Add(pageName, p);
}
return p;
}
NLog.ILogger logger = NLog.LogManager.GetCurrentClassLogger();
......
......@@ -84,9 +84,8 @@ namespace MultiLayout
var page = await manager.LoadModule();
NavigationService.Navigate(page);
page.Loaded += (s, e1) =>
frame.NavigationService.RemoveBackEntry();
//加载主页面后 删除 PgLoading 页面
page.Loaded += Page_Loaded;
//---------------------------------------------------------
//初始化
await manager.OnInit();
......@@ -104,6 +103,14 @@ namespace MultiLayout
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
var page = sender as Page;
page.Loaded -= Page_Loaded;
NavigationService.RemoveBackEntry();
}
private void btnErrMsgClick(object sender, RoutedEventArgs e)
{
manager.ErrMsgClick?.Invoke();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment