MvvMCross导航回多个viewmodels / truncate导航堆栈 [英] MvvMCross navigate back multiple viewmodels / truncate navigation stack

查看:154
本文介绍了MvvMCross导航回多个viewmodels / truncate导航堆栈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个关于MvvMCross导航的问题。

I have two questions regarding navigation in MvvMCross.


  1. 如何返回导航堆栈上的视图模型?分别:如何返回指定数量的视图模型?

  2. 如何截断导航堆栈?

  1. How can I go back to a view model, that is on the navigation stack? Respectively: How can I go back a specified number of view models?
  2. How can I truncate the navigation stack?

例如: A | B | C 在堆栈上,导航到D使堆栈看起来像: D

e.g: A|B|C on the stack, navigating to D makes the stack look like: D


推荐答案

操纵后台堆栈的功能是平台和应用程序特定的 - 例如:

The functionality for manipulating the back stack is platform and app specific - e.g:


  • 这是非常不同的操纵一个Android活动backstack而不是iOS UINavigation控制器

  • 这取决于你的应用程序是否使用标签,活动,片段,弹出窗口,模态,汉堡菜单等。

因此,在MvvmCross中没有定义像这样的UI更改的实际实现。

Because of this, the actual implementation of UI changes like this is not defined within MvvmCross.

,你可以在你的应用程序中实现 presenter

Instead, it's up to you to implement in your applications presenter.

你需要遵循的基本流程是:

The basic flow you'll need to follow is:


  1. 确定您的应用结构是什么以及您希望实现的效果

  1. Work out what your app structure is and what effect(s) you want to achieve

For这个效果,声明一个自定义的演示提示 - 例如

For this effect, declare a custom presentation hint - e.g



    public class MyFunkyPresentationHint : MvxPresentationHint
    {
        public int DegreeOfFunkiness { get; set; } 
    }




  1. 你可以创建并从任何ViewModel发送此提示



    base.ChangePresentation(new MyFunkyPresentationHint() { DegreeOfFunkiness=27 });




  1. 在您的自定义演示者中,您可以执行此操作你想要的后台屏幕黑客攻击:



    public override void ChangePresentation(MvxPresentationHint hint)
    {
        if (hint is MyFunkyPresentationHint)
        {
            // your code goes here
            return;
        }

        base.ChangePresentation(hint);
    }






有关自定义演示者的示例,请参阅: http://slodge.blogspot.com/2013/06/presenter- roundup.html

有关backstack操作的一个示例,请参阅如何实现 Close(this)在某些标准演示者中。

For one example of backstack manipulation, see how Close(this) is implemented in some of the standard presenters.

这篇关于MvvMCross导航回多个viewmodels / truncate导航堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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