MVVM消息传递与RaisePropertyChanged< T> [英] MVVM Messaging vs RaisePropertyChanged<T>

查看:42
本文介绍了MVVM消息传递与RaisePropertyChanged< T>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. MVVM消息传递和RaisePropertyChanged之间有什么区别.

  1. What is the difference between MVVM messaging and RaisePropertyChanged.

我正在尝试在视图模型B中的属性发生更改时在视图模型A中运行一个函数,哪种方法更适合使用-Messaging或RaisePropertyChanged广播?

I'm trying to run a function in View model A when a property in view model B changes, which approach is a better one to use - Messaging or RaisePropertyChanged broadcast?

谢谢, 尼基尔

推荐答案

  1. 消息传递使您的视图模型脱钩.这就像一条推文,您向空中发送一条消息,有人可以阅读它,也可以有人注册来收听. UI使用PropertyChanged来了解某些更改并重新绘制值.

  1. Messaging decouples your view models. It's like a Tweet, you send out a message into the air and someone can read it or someone could register to listen for it. PropertyChanged is used by the UI to know that something changed and to redraw the values.

消息传递绝对是最佳选择. MVVM指示灯具有内置选项来广播消息.您可以使用mvvminpc代码段.

Messaging is definitely the best choice. MVVM light has a built in option to broadcast the message. You can use the mvvminpc code snippet.

令人惊讶的是,您的帖子没有得到尽快答复.也许这个答案对外面的人还是有用的.

It's surprising your post wasn't answered sooner. Maybe this answer will still be useful to someone out there.

这篇关于MVVM消息传递与RaisePropertyChanged< T>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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