tags:

views:

72

answers:

1

I am abit confused about how to setup the messaging between views. What I am doing is using a radtabcontrol in my mainpage. Each view that is launched after that is bound to a new tab. When the tab needs to be terminated, i.e. user requests a close or it is no longer required, I need to communicate back to the mainpage so it can terminate the view and close the tab.

Can someone help me find a tutorial or perhaps provide sample code using Messenger and RelayCommand to do this?

A: 

In the constructor of your MainPage (or whatever):

Messenger.Default.Register<string>(this, MessageReceived);


The MessageReceived method (also in MainPage):

private void MessageReceived(string message)
{
    if (message == "SomeTabWasClosed")
    {
        //Do the necessary clean-up
    }
}


Then when you need to send the message (maybe in your tab Views or their ViewModels):

Messenger.Default.Send("SomeTabWasClosed");
Henrik Söderlund