Publishing and Subscribing to Messages

Learn how to publish messages inside a MAUI app and subscribe to them.

.NET MAUI has a built-in mechanism for publishing messages and subscribing to them. This mechanism allows us to share instructions between any components inside the application without them having to call each other's methods directly.

Publishing and subscribing are done by the static MessagingCenter class. Because this class is static, a subscriber to the message can be any object within the application. To demonstrate how it works, we have the following project setup:

Get hands-on with 1400+ tech skills courses.