MessagingCenter Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Associates a callback on subscribers with a specific message name.
public class MessagingCenter : Xamarin.Forms.IMessagingCenter
type MessagingCenter = class
interface IMessagingCenter
- Inheritance
-
System.ObjectMessagingCenter
- Implements
Remarks
The following shows a simple example of a strongly-typed callback using MessagingCenter is:
public class SubscriberThing
{
public int IntProperty { get; set; }
}
var subscriber = new SubscriberThing();
MessagingCenter.Subscribe<MyPage, int> (subscriber, "IntPropertyMessage", (s, e) => {
subscriber.IntProperty = e;
});
//...later...
MessagingCenter.Send<MyPage, int>(this, "IntPropertyMessage", 2);
Assert.AreEqual(2, subscriber.IntProperty);
Constructors
MessagingCenter() |
Creates a new MessagingCenter with default values. |
Properties
Instance |
Gets the singleton instance of the MessagingCenter. |
Methods
Send<TSender,TArgs>(TSender, String, TArgs) |
Sends a named message with the specified arguments. |
Send<TSender>(TSender, String) |
Sends a named message that has no arguments. |
Subscribe<TSender,TArgs>(Object, String, Action<TSender,TArgs>, TSender) |
Run the |
Subscribe<TSender>(Object, String, Action<TSender>, TSender) |
Run the |
Unsubscribe<TSender,TArgs>(Object, String) |
Unsubscribes from the specified parameterless subscriber messages. |
Unsubscribe<TSender>(Object, String) |
Unsubscribes a subscriber from the specified messages that come from the specified sender. |
Explicit Interface Implementations
IMessagingCenter.Send<TSender,TArgs>(TSender, String, TArgs) |
Sends a message and arguments to objects that are listening for them on the type that is specified by |
IMessagingCenter.Send<TSender>(TSender, String) |
Sends the named parameterless message to objects that are listening for it on the type that is specified by |
IMessagingCenter.Subscribe<TSender,TArgs>(Object, String, Action<TSender,TArgs>, TSender) |
Subscribes to the specified |
IMessagingCenter.Subscribe<TSender>(Object, String, Action<TSender>, TSender) |
Subscribes to the specified |
IMessagingCenter.Unsubscribe<TSender,TArgs>(Object, String) |
Unsubscribes the specified |
IMessagingCenter.Unsubscribe<TSender>(Object, String) |
Unsubscribes the specified |