开发者

Communication between views

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开发者_StackOverflow中文版 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?


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");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜