MVVM 类似向导

发布于 2024-09-10 15:37:27 字数 289 浏览 9 评论 0原文

我目前正在构建一个基于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

っ〆星空下的拥抱 2024-09-17 15:37:27

您是否读过代码项目中两位 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

黯然#的苍凉 2024-09-17 15:37:27

您可以查看 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.

给不了的爱 2024-09-17 15:37:27

如果您的向导有一个单独的虚拟机,用于存储每个步骤的状态/结果,并位于用户控件的视图后面...

您可以在向导视图上有一个框架,该框架需要后面的代码中的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文