导航基于MVVM的应用 [英] Navigation in MVVM based application

查看:142
本文介绍了导航基于MVVM的应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在设计一个具有复杂的依赖于模型\\用户安全等和其他一些环境因素的状态XBAP应用程序,用户可配置的导航流程。

we are designing a xbap application that has complex, user configurable navigation flow that depend on state of the model\user security etc and some other environmental factors.

该应用程序具有加载框内部用户特定的控件的容器观点,我想知道什么的preferred实践具有导航逻辑,一个单独的控制器内或在容器视图的视图模型..

The application is having a container view that loads user specific controls inside a Frame, i am wondering whats the preferred practice for having the navigation logic, inside a separate controller or in the viewmodel of the container view..

推荐答案

我会把导航流code在某种全局控制器或服务。你可能不希望您的视图或视图模型有这样的逻辑,因为他们会拉了不少依赖他们,特别是如果你的流量是相当复杂的,可定制的。相反,你希望这些意见和视图模型可以很容易地单元测试的,在这种情况下,他们将推迟时,他们做了人谁是在一个更好的位置,做出适当的决定会发生什么。

I would put the navigation flow code in a global controller or service of some kind. You probably don't want your views or view models to have such logic because they would pull quite a lot of dependencies to them, especially if your flow is quite complex and customizable. Instead, you want those views and view models to be easily unit-testable, in which case they would defer what happens when they're done to somebody who's in a better position to make the appropriate decision.

这篇关于导航基于MVVM的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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