Messaging - sending message to specific recipient.

Jul 30, 2010 at 2:40 PM

I am finally using the MVVMLight Messaging bus and find that it is absolutely AWESOME!!

However, I have a list of items that i am editing and want to Send a message to notify the edited object (item) in the main list control  that editing was a success and to change the display message to the appropriate value. See Below...

---- Start off by registering notification for fixed errors (in constructor) then send the item to be edited (in function)

Messenger.Default.Register<bool>(this"AllErrorsFixed", a => { ErrorsFixed(a); });
Messenger.Default.Send<FileStructure>(this"EditThisItem");

---- Now Reply that the edit is complete (in Popup Child window) 

Messenger.Default.Send<bool>(true"AllErrorsFixed");

 

Here is where I need help… I have a list of items that may need editing, however, when the notification of “AllErrorsFixed” goes out it is sent to every item therefore they all show that their errors have been fixed. I only want to send it to the item in my original list that was chosen.

Is this even possible?

BTW: I am using a HyperlinkButton that is part of a List Template to send the "EditThisItem" and open the Popup edit window.

Thanks,

ShadowDog.

 




 

Jul 30, 2010 at 2:50 PM

Wow, I got it... 

After detailing my problem out it made me think a little and within a minute of posting this I have it fixed (I believe?)

Here is what I did...

--- Register the notification for fixed errors and then send the item to be edited (both in the same function - don't register "AllErrorsFixed" in the Constructor)

Messenger.Default.Register<bool>(this"AllErrorsFixed", a => { ErrorsFixed(a); });
Messenger.Default.Send<FileStructure>(this"EditThisItem");

By registering the "AllErrorsFixed" in the function before I called "EditThisItem", only the item that was being edited will receive the response of "AllErrorsFixed" and therefore will be the only one that is changed to 'fixed'.

Now my question is - will this edited object always receive the "AllErrorsFixed" forever? Is there anyway to unregister it?

What would be correct?

 

-SD