Send a empty Message or Notification with MVVM toolkit light

后端 未结 4 863
故里飘歌
故里飘歌 2021-01-22 00:14

I\'m using the MVVM Light Toolkit. I could not find any Ctor of Messenger or Notification class to send a empty message.

ViewModel1:

 private int _select         


        
4条回答
  •  旧时难觅i
    2021-01-22 01:12

    There really isn't a way to accomplish this and in someways defies the point of the messenger class. I didn't want to write a your doing it wrong post, but I feel I am stuck. The way the messenger class works is that you have two parties that both subscribe to the same concept, its an observer model. Without that similar concept or message there really isn't a way to tie the two objects together. The generic message whether a simple string or custom message act as the meeting point of the Subscribing and Publishing classes.

    If the ViewModel publishing knows the type of ViewModel its trying to Send to it could...

    Messenger.Default.Send(typeof(ViewModelToSendTo);
    

    This would act as a very simple interaction point, you also wouldn't have to create a custom class. Some purist may have an issue with this approach as it couples the publishing class to the subscriber.

提交回复
热议问题