我想创建一个Windows 8地铁风格的应用程序用C#。我的问题是框架控制:如果我使用它,而 NavigationCacheMode =必需,每个用户可以追溯到时候,页是不保留在内存中,将被重新创建。如果设置了 NavigationCacheMode 到必需或已启用,回去正常工作(没有新的页面对象)的,但如果我浏览到另一页从同一个类型,previous页面对象被回收再利用(没有新的页面实例)。
I'm trying to create a Windows 8 Metro styled application with C#. My problem is the Frame control: If I use it without NavigationCacheMode = Required, every time the user goes back, the page is not kept in memory and will be recreated. If I set NavigationCacheMode to Required or Enabled, going back works correctly (no new page object) but if I navigate to another page from the same type, the previous page object is recycled and reused (no new page instance).
期望的行为:
有没有办法有一个与原始的框架控件(如Windows Phone中)以下行为:
Is there a way to have the following behaviour with the original Frame control (like in Windows Phone):
我知道的唯一解决方案是创建一个自己的框架控制,但是这会导致其他问题(如:缺少 SetNavigationState()法,等...)
The only solution I know is to create an own Frame control but this leads to other problems (e.g.: missing SetNavigationState() method, etc...)
示例场景:
有三页简单的应用例如: TvShowListPage , TvShowDetailsPage , SeasonDetailsPage 。
Simple application example with three pages: TvShowListPage, TvShowDetailsPage, SeasonDetailsPage.
我在寻找默认的Windows Phone 7的行为:创建导航页面上堆了新的一页,回去从栈中删除顶部页面,并显示堆栈中的previous页(存储在内存中)。
I'm looking for the default Windows Phone 7 behavior: Navigating creates a new page on the page stack, going back removes the top page from the stack and displays the previous page from the stack (stored in the memory).
解决方法:
由于没有解决这个问题,我不得不重新实现所有分页相关的类:页,框架,SuspensionManager,等等...
Because there was no solution to this problem, I had to reimplement all paging relevant classes: Page, Frame, SuspensionManager, etc...
在库MyToolkit 它提供了所有这些类可以在这里下载:github/MyToolkit/MyToolkit/wiki/Paging-Overview
The library MyToolkit which provides all these classes can be downloaded here: github/MyToolkit/MyToolkit/wiki/Paging-Overview
参考文献:
- www.jayway/2012/05/25/clearing-the-windows-8-page-cache/:没有很好的解决办法
- social.msdn.microsoft/Forums/en-US/winappswithcsharp/thread/88e6d1b3-1fa6-4ab4-a816-e77c86ef236f/:一个自己的框架类的实现是无解的,因为它不与 SuspensionManager 工作
- www.jayway/2012/05/25/clearing-the-windows-8-page-cache/: No good solution
- social.msdn.microsoft/Forums/en-US/winappswithcsharp/thread/88e6d1b3-1fa6-4ab4-a816-e77c86ef236f/: Implementing of an own Frame class is no solution as it doesn't work with SuspensionManager
由于没有解决这个问题,我不得不重新实现所有分页相关的类:页,框架,SuspensionManager,等等...
Because there was no solution to this problem, I had to reimplement all paging relevant classes: Page, Frame, SuspensionManager, etc...
该解决方案可以在这里下载: github/MyToolkit/MyToolkit/wiki/Paging-Overview
The solution can be downloaded here: github/MyToolkit/MyToolkit/wiki/Paging-Overview
更新:
页面类现在还提供了 OnNavigatingFromAsync 方式来显示例如异步弹出,如果需要取消导航...
The page class now also provides the OnNavigatingFromAsync method to show for example an async popup and cancel navigation if required...
更多推荐
WinRT的框架和页面缓存:如何创建导航(新页面实例),并保持在页面实例上GoBack的()
发布评论