作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我刚刚开始使用MVVM Light framework学习Silverlight。最近,我开始接触MVVM Light中的Messenger功能。
到目前为止,我已经下载并挖掘了Laurent发表的Clean Shutdown example,并且对Messenger类的工作原理有基本的了解,但是我仍然不确定何时使用哪种Message类型。
在网站上,以下是消息类型:
- MessageBase: A simple message class, carrying optional information about the message's sender.
- GenericMessage: A simple message with a Content property of type T.
- NotificationMessage: Used to send a notification (as a string) to a recipient. For example, save your notifications as constant in a Notifications class, and then send Notifications.Save to a recipient.
- NotificationMessage: Same as above, but with a generic Content property. Can be used to pass a parameter to the recipient together with the notification.
- NotificationMessageAction: Sends a notification to a recipient and allows the recipient to call the sender back.
- NotificationMessageAction: Sends a notification to a recipient and allows the recipient to call the sender back with a generic parameter.
- DialogMessage: Used to request that a recipient (typically a View) displays a dialog, and passes the result back to the caller (using a callback). The recipient can choose how to display the dialog, either with a standard MessageBox, with a custom popup, etc…
- PropertyChangedMessage: Used to broadcast that a property changed in the sender. Fulfills the same purpose than the PropertyChanged event, but in a less tight way.
最佳答案
如果您不尝试使编码适合消息,而是使消息做您想要的事情,那么您将为自己省去很多麻烦和烦恼。不要害怕对消息进行子类化,以使它们执行您真正想要的消息。那是我在使用mvvm-light时遇到的第一个错误。
我的大多数邮件都使用GenericMessage,而Generic是我要传输的内容...
例如我有一个ExceptionMessage类,
Public ExceptionMessage:GenericMessage<System.Exception>
关于silverlight - MVVM Light消息类型: When to use each type?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6282873/
我是一名优秀的程序员,十分优秀!