MvvmCross删除后退堆栈Windows应用程序 [英] MvvmCross remove back stack windows app

查看:88
本文介绍了MvvmCross删除后退堆栈Windows应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何清除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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆