如何在WPF应用程序中组合MVVM和依赖注入? [英] How can I combine MVVM and Dependency Injection in a WPF app?

查看:117
本文介绍了如何在WPF应用程序中组合MVVM和依赖注入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你可以举一个例子,说明你如何使用(你最喜欢的)DI框架为WPF应用程序提供MVVM查看模型?



你会创建一个强大的视图模型的连接层次结构(如每个嵌套控件的ViewModel是父级ViewModel上的属性,并将其绑定到XAML中的嵌套控件的DataContext),或者您将使用某种甚至更抽象的View ModelManager ,它保持一些弱连接的层次结构...像在CAB中,也许?

解决方案

看看Unity和Prism有Mike Taulty的一系列视频开始这里填写项目链接。


Can you please give an example of how you would use (your favorite) DI framework to wire MVVM View Models for a WPF app?

Will you create a strongly-connected hierarchy of View Models (like where every nested control's ViewModel is a property on a parent's ViewModel and you bind it to nested control's DataContext in XAML) or you would use some kind of even-more-abstract ""View Model" Manager", which maintains some weakly-connected hierarchy... like in CAB, maybe?

解决方案

Take a look at Unity and Prism there's a series of video's by Mike Taulty that start here complete with links to the projects.

这篇关于如何在WPF应用程序中组合MVVM和依赖注入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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