共用方式為


IMessagingCenter.Subscribe Method

Definition

Overloads

Subscribe<TSender,TArgs>(Object, String, Action<TSender,TArgs>, TSender)

Run the callback on subscriber in response to parameterized messages that are named message and that are created by source.

Subscribe<TSender>(Object, String, Action<TSender>, TSender)

Run the callback on subscriber in response to messages that are named message and that are created by source.

Subscribe<TSender,TArgs>(Object, String, Action<TSender,TArgs>, TSender)

Run the callback on subscriber in response to parameterized messages that are named message and that are created by source.

public void Subscribe<TSender,TArgs> (object subscriber, string message, Action<TSender,TArgs> callback, TSender source = default) where TSender : class;
abstract member Subscribe : obj * string * Action<'Sender, 'Args (requires 'Sender : null)> * 'Sender -> unit (requires 'Sender : null)

Type Parameters

TSender

The type of object that sends the message.

TArgs

The type of the objects that are used as message arguments for the message.

Parameters

subscriber
System.Object

The object that is subscribing to the messages. Typically, this is specified with the this keyword used within the subscribing object.

message
System.String

The message that will be sent to objects that are listening for the message from instances of type TSender.

callback
System.Action<TSender,TArgs>

A callback, which takes the sender and arguments as parameters, that is run when the message is received by the subscriber.

source
TSender

The object that will send the messages.

Applies to

Subscribe<TSender>(Object, String, Action<TSender>, TSender)

Run the callback on subscriber in response to messages that are named message and that are created by source.

public void Subscribe<TSender> (object subscriber, string message, Action<TSender> callback, TSender source = default) where TSender : class;
abstract member Subscribe : obj * string * Action<'Sender (requires 'Sender : null)> * 'Sender -> unit (requires 'Sender : null)

Type Parameters

TSender

The type of object that sends the message.

Parameters

subscriber
System.Object

The object that is subscribing to the messages. Typically, this is specified with the this keyword used within the subscribing object.

message
System.String

The message that will be sent to objects that are listening for the message from instances of type TSender.

callback
System.Action<TSender>

A callback, which takes the sender and arguments as parameters, that is run when the message is received by the subscriber.

source
TSender

The object that will send the messages.

Applies to