본문 바로가기

.NET/MVVM Light

[MVVM-Light] View와 View 사이 통신

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