Created
June 14, 2016 23:55
-
-
Save Driv4r/b82dec31f8e10495d6f2de62ab85ee4e to your computer and use it in GitHub Desktop.
Simple Xamarin MessagingCenter example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Without sending arguments | |
//Subscribe | |
MessagingCenter.Subscribe<object> (this, "Arrived", (sender) => { | |
// do something whenever the "Arrived" message is sent from whatever type | |
//<object> is. | |
}); | |
//Send | |
//All subscribers to "Arrived" of type "this" will be notified. | |
MessagingCenter.Send<object> (this, "Arrived"); | |
//Unsubscribe | |
MessagingCenter.Unsubscribe<object> (this, "Arrived"); | |
//With sending arguments. | |
//Subscribe | |
MessagingCenter.Subscribe<object, string> (this, "Arrived", (sender, string) => { | |
// do something whenever the "Arrived" message is sent from whatever type | |
//<object> is. | |
myEntry.Text = string; | |
}); | |
//Send | |
//All subscribers to "Arrived" of type "this" will be notified. | |
MessagingCenter.Send<object, string> (this, "Arrived", "New String"); | |
//Unsubscribe | |
MessagingCenter.Unsubscribe<object, string> (this, "Arrived"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment