MVVM 类似向导
我目前正在构建一个基于 MVVM 的应用程序。应用程序还应该有一个 MVVM 风格的向导。巫师不是普通的巫师,而是一种特殊的巫师。我的目标是实现一个
具有多个分支的向导 1.)。该向导可以引导您走向其他方向。所以巫师一定不简单。
2.) 也可以有捷径。您可以跳过一些设置了默认值的页面。
3.) 也是正常的——简单明了。
请注意,wizrad 页面中的某些信息是动态的。这意味着信息可以在每个步骤之间传递并进行处理。
有没有像模式这样的方法来解决我的问题?我如何以最佳方式实施它?
I am currently building an MVVM based application. The application should also have a wizard in MVVM style. The wizard is not a normal wizard, its a particular kind of a wizard. My goal is to implement a wizard with
1.) has also multiple branches. The wizard can guide you in other direction. So the wizard must not be straightforward.
2.) can also have short cuts. You can skip some pages where default values are setted.
3.) is also normal - straightforward.
Note, some information in the wizrad pages are on-the-fly. That means, that the information can be passed between each step and processed.
Are there any approaches like patterns to solve my problem? How do I implement it the best way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否读过代码项目中两位 MVVM 大师撰写的关于 MVVM 向导的好文章:
http://www.codeproject.com/KB/WPF/InternationalizedWizard.aspx ?显示=打印
Did you read this good article in Code Project about Wizard in MVVM and written by two MVVM guru:
http://www.codeproject.com/KB/WPF/InternationalizedWizard.aspx?display=Print
您可以查看 WPF 应用程序框架 (WAF) 的 ViewModel 示例应用程序。它展示了如何以 MVVM 方式实现向导。
You might have a look at the ViewModel sample application of the WPF Application Framework (WAF). It shows how to implement a Wizard in a MVVM way.
如果您的向导有一个单独的虚拟机,用于存储每个步骤的状态/结果,并位于用户控件的视图后面...
您可以在向导视图上有一个框架,该框架需要后面的代码中的 2 个事件(这显然取决于关于您的 MVVM 架构是否可以忍受?)。
事件 1) 当向导步骤的绑定引发其 NotifyPropertyChanged 时:告诉框架“导航”到适当的页面(如向导 VM 中的属性中所述)。
事件 2) 在框架“导航”事件上,以便您可以将当前页面数据上下文指向您的 VM。
这样,向导视图模型就可以控制向导从开始到结束的状态,并且还可以描述步骤,可以轻松地添加、编辑等。
显然,这可能不符合每个人对 MVVM 的看法。
If your wizard has a single VM that stores the state/results of each step and sits behind a view that is a user control...
You could have a Frame on the wizard view that requires 2 events in the code behind (This obviously depends on if your MVVM architecture can live with this?).
Event 1) When the binding of your wizards step raises its NotifyPropertyChanged: tell your frame to "Navigate" to the appropriate page (as described in a property in your wizard VM).
Event 2) On the frames "Navigated" event so that you can point the current pages data-context at your VM.
This way the wizard viewmodel controls the state of the wizard from start to finish and it also can describe the steps, which can easily be added to, edited, etc.
Obviously this may not sit well with everyone's view of MVVM.