MvvmCross删除后退堆栈Windows应用程序 [英] MvvmCross remove back stack windows app
问题描述
如何清除Windows应用程序(不是Windows Phone)中的后堆栈?
我正在使用MvvmCross v3.最正确的放置位置在哪里?
How can I clear the back stack in windows apps (not windows phone)?
I am using MvvmCross v3. Where is the most correct place to put it?
我已阅读此帖子 http://edsnider.net/2014/04/07/clearing-windows-phone-nav-back-stack-in-mvvmcross/他正在使用 CustomWP8ViewPresenter
I have read this post http://edsnider.net/2014/04/07/clearing-windows-phone-nav-back-stack-in-mvvmcross/ where he is using CustomWP8ViewPresenter
public override void ChangePresentation(MvxPresentationHint hint)
{
if (hint is ClearNavBackStackHint)
{
while (RootFrame.BackStack.Any())
{
RootFrame.RemoveBackEntry();
}
}
base.ChangePresentation(hint);
}
我的问题是,在Windows应用程序中,我没有 RootFrame.RemoveBackEntry()作为选项.
My problem is that in windows app I do not have RootFrame.RemoveBackEntry() as an option.
有什么想法吗?
推荐答案
注释中提到的IMvxWindowsFrame
只是对Windows.UI.Xaml.Controls.Frame
实例的简单包装.您可以通过调用以下方法获取此包装好的实例:
Your IMvxWindowsFrame
mentioned in comments is just simple wrapper around Windows.UI.Xaml.Controls.Frame
instance. You can get this wrapped instance by calling:
_rootFrame = (Frame) rootFrame.UnderlyingControl;
然后您可以像这样删除后退堆栈:
Then you can delete your backstack like this:
if (hint is ClearNavBackStackHint)
{
if (_rootFrame.BackStackDepth > 0)
{
_rootFrame.BackStack.RemoveAt(_rootFrame.BackStack.Count - 1);
}
}
这篇关于MvvmCross删除后退堆栈Windows应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!