Xamarin Forms Messaging Center

Hi friends,

In this article, we will talk about Messaging Center which is one of the most used features in Xamarin Forms. As the name of the Messaging Center implies, it is cross-page messaging. If you have had Native application development experience before, you can do it with Notification Center on iOS with Swift. We use the Messaging Center for many reasons. These; printing error message on the screen, performing the same operation on each page at the same time, sending news before 2 3 pages, data flow between pages etc. use cases. Very simple to use.

The Messaging Center has the part that receives a message and the part that sends the message. The part that receives the message must first mention it on that page. What it needs here is a value and the type of message that comes with this value is important when the message is sent. Let’s make an example. This example should show a message on the screen that a successful operation is successful.

First of all you need to register this message in the App class in order to display this message from all pages. Normally you can only register on one page, but you need to register in App.cs to show it on all pages. The way you register is actually very simple. Subscribe and specify the type of return. Then we tell you which page will be registered for this message and write which message should be registered. Then, if we get this message, we do what we do not.

After that, the message remains. Sending a message is a much simpler process. You only write what type of message you want to send and what message you send. Then you write the Key to which message to send.

One thought on “Xamarin Forms Messaging Center

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.