MvvmCross remove back stack windows app

一笑奈何 提交于 2019-12-13 19:50:45

问题


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?

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);
    }

My problem is that in windows app I do not have RootFrame.RemoveBackEntry() as an option.

Any ideas?


回答1:


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);
    }
}


来源:https://stackoverflow.com/questions/30499757/mvvmcross-remove-back-stack-windows-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!