ObservableRecipient

Ecng.ComponentModel

A view-model base that participates in IMessenger messaging. While IsActive is true the instance is registered for every IRecipient it implements; property changes can be broadcast as PropertyChangedMessage. The shape mirrors CommunityToolkit.Mvvm.ComponentModel.ObservableRecipient.

継承元: NotifiableObject

コンストラクター

ObservableRecipient
protected ObservableRecipient()
observableRecipient = ObservableRecipient()

Initializes a new instance using Default.

ObservableRecipient
protected ObservableRecipient(IMessenger messenger)
observableRecipient = ObservableRecipient(messenger)

Initializes a new instance with the specified messenger.

messenger
The messenger to use.

プロパティ

IsActive
public bool IsActive { get; set; }
value = observableRecipient.IsActive
observableRecipient.IsActive = value

Gets or sets whether this recipient is active. Activating registers its IRecipient handlers; deactivating unregisters them.

Messenger
protected IMessenger Messenger { get; }
value = observableRecipient.Messenger

The messenger this recipient uses.

メソッド

Broadcast``1
protected void Broadcast<T>(T oldValue, T newValue, string propertyName)
observableRecipient.Broadcast(oldValue, newValue, propertyName)

Broadcasts a PropertyChangedMessage for a property change.

oldValue
The previous value.
newValue
The new value.
propertyName
The property name.
OnActivated
protected virtual void OnActivated()
observableRecipient.OnActivated()

Called when IsActive becomes true. Registers all implemented IRecipient handlers by default.

OnDeactivated
protected virtual void OnDeactivated()
observableRecipient.OnDeactivated()

Called when IsActive becomes false. Unregisters this recipient by default.

SetProperty``1
protected bool SetProperty<T>(T field, T newValue, bool broadcast, string propertyName)
result = observableRecipient.SetProperty(field, newValue, broadcast, propertyName)

Sets a field, raising change notification and optionally broadcasting the change.

field
The backing field.
newValue
The new value.
broadcast
Whether to broadcast a PropertyChangedMessage.
propertyName
The property name (auto-filled).

戻り値: true if the value changed.