Tutorial by Examples

Here we will see a simple example of using the MessagingCenter in Xamarin.Forms. First, let's have a look at subscribing to a message. In the FooMessaging model we subscribe to a message coming from the MainPage. The message should be "Hi" and when we receive it, we register a handler wh...
You can also pass arguments with a message to work with. We will use the classed from our previous example and extend them. In the receiving part, right behind the Subscribe method call add the type of the argument you are expecting. Also make sure you also declare the arguments in the handler sign...
When you no longer need to receive messages, you can simply unsubscribe. You can do it like this: MessagingCenter.Unsubscribe<MainPage> (this, "Hi"); When you are supplying arguments, you have to unsubscribe from the complete signature, like this: MessagingCenter.Unsubscribe<Ma...

Page 1 of 1