通信的两个视图模型在WPF MVVM [英] Communicate two view models in WPF MVVM
问题描述
我开发一个WPF应用程序,我有一些问题相互通信一个视图模式。
I am developing a WPF application and I have some problems to communicate one view model with another.
我有:
- MainViewModel
- ChildViewModel1
- ChildViewModel2
每一次在MainViewModel,ChildViewModel1和ChildViewModel2属性变化应该得到通知。
Every time a property changes in MainViewModel, ChildViewModel1 and ChildViewModel2 should get notified.
任何人都可以提出一个解决办法?
Can anyone suggest a workaround?
编辑:
我想在一个解决方案descrided MVVM光(<一个href=\"http://simplemvvmtoolkit.$c$cplex.com/SourceControl/changeset/view/23821#313594.\">http://simplemvvmtoolkit.$c$cplex.com/SourceControl/changeset/view/23821#313594.),正在实施的消息总线,它是正确的做法?
I am thinking in a solution descrided MVVM Light (http://simplemvvmtoolkit.codeplex.com/SourceControl/changeset/view/23821#313594.), that is implementing a message bus. Is it the right approach?
推荐答案
有关的ViewModels之间进行相互沟通的常见方式
是theMediator设计模式的执行力度。
the common way for viewmodels to communicate between themselves is implimentation of theMediator design pattern
在这里是怎么回事在MVVMLight完成
<一href=\"http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/27aaefff-e463-451c-87d9-37367a343e0e\">http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/27aaefff-e463-451c-87d9-37367a343e0e
here is how it is done in MVVMLight http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/27aaefff-e463-451c-87d9-37367a343e0e
在棱镜:
<一href=\"http://blogs.u2u.be/diederik/post/2011/01/15/Using-the-Prism-40-Event-Aggregator.aspx\">http://blogs.u2u.be/diederik/post/2011/01/15/Using-the-Prism-40-Event-Aggregator.aspx
在卡利是:
<一href=\"http://www.mindscapehq.com/blog/index.php/2012/02/01/caliburn-micro-part-4-the-event-aggregator/\">http://www.mindscapehq.com/blog/index.php/2012/02/01/caliburn-micro-part-4-the-event-aggregator/
这篇关于通信的两个视图模型在WPF MVVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!