mvvm light - messaging

时间秒杀一切 提交于 2019-12-06 21:58:06

问题


I'm curently teaching myself the MVVM pattern. I've hit my first snag with the concept of messaging. I know messaging is contained in the mvvm-light toolkit. But I cannot find an example of usage anywhere (no sample projects are provided in the download).

If anyone can direct me to some information as to how to use messaging in that toolkit, that would be ace.

Thanks


回答1:


I found the following article on the subject. The subject line seems a little unrelated but that link is for part 2 of the article and if you read and scroll down a bit you will find info on the RelayCommand, Messenger, EventToCommand, and ICleanup.

http://www.codeproject.com/KB/silverlight/IssueVisionSilverlightPt2.aspx

Good luck.




回答2:


I have posted an example of using Messaging here, as part of my Intro to MVVM Light series.

My goal in this example is to send a message indicating that navigation is needed. The VM can't manage the navigation so it sends a message to the view. We do this in three steps:

  1. Create a class to contain the message that is to be passed
  2. In the view model, instantiate the message class and broadcast the message
  3. Within MainPage.xaml.cs register for the message and handle it when received

The complete source code is posted and also available for download.




回答3:


http://blog.galasoft.ch/archive/2009/09/27/mvvm-light-toolkit-messenger-v2-beta.aspx

Here abit about it.

/Bo




回答4:


I posted some simple MVVM Light messaging code on this other question with sample compiled code and explanations.

Send a empty Message or Notification with MVVM toolkit light

Cheers, Mario



来源:https://stackoverflow.com/questions/4426559/mvvm-light-messaging

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!