Bearbeiten

Freigeben über


ObservableRecipient.SetProperty Method

Definition

Overloads

SetProperty<T>(T, T, Boolean, String)

Compares the current and new values for a given property. If the value has changed, raises the PropertyChanging event, updates the property with the new value, then raises the PropertyChanged event.

SetProperty<T>(T, T, Action<T>, Boolean, String)

Compares the current and new values for a given property. If the value has changed, raises the PropertyChanging event, updates the property with the new value, then raises the PropertyChanged event. Similarly to the SetProperty<T>(T, T, Action<T>, String) method, this overload should only be used when SetProperty<T>(T, T, String) can't be used directly.

SetProperty<T>(T, T, IEqualityComparer<T>, Boolean, String)

Compares the current and new values for a given property. If the value has changed, raises the PropertyChanging event, updates the property with the new value, then raises the PropertyChanged event. See additional notes about this overload in SetProperty<T>(T, T, Boolean, String).

SetProperty<T>(T, T, IEqualityComparer<T>, Action<T>, Boolean, String)

Compares the current and new values for a given property. If the value has changed, raises the PropertyChanging event, updates the property with the new value, then raises the PropertyChanged event. See additional notes about this overload in SetProperty<T>(T, T, Action<T>, Boolean, String).

SetProperty<TModel,T>(T, T, TModel, Action<TModel,T>, Boolean, String)

Compares the current and new values for a given nested property. If the value has changed, raises the PropertyChanging event, updates the property and then raises the PropertyChanged event. The behavior mirrors that of SetProperty<TModel,T>(T, T, TModel, Action<TModel,T>, String), with the difference being that this method is used to relay properties from a wrapped model in the current instance. For more info, see the docs for SetProperty<TModel,T>(T, T, TModel, Action<TModel,T>, String).

SetProperty<TModel,T>(T, T, IEqualityComparer<T>, TModel, Action<TModel,T>, Boolean, String)

Compares the current and new values for a given nested property. If the value has changed, raises the PropertyChanging event, updates the property and then raises the PropertyChanged event. The behavior mirrors that of SetProperty<TModel,T>(T, T, IEqualityComparer<T>, TModel, Action<TModel,T>, String), with the difference being that this method is used to relay properties from a wrapped model in the current instance. For more info, see the docs for SetProperty<TModel,T>(T, T, IEqualityComparer<T>, TModel, Action<TModel,T>, String).

SetProperty<T>(T, T, Boolean, String)

Compares the current and new values for a given property. If the value has changed, raises the PropertyChanging event, updates the property with the new value, then raises the PropertyChanged event.

protected bool SetProperty<T> (ref T field, T newValue, bool broadcast, string? propertyName = default);
override this.SetProperty : 'T * 'T * bool * string -> bool
Protected Function SetProperty(Of T) (ByRef field As T, newValue As T, broadcast As Boolean, Optional propertyName As String = Nothing) As Boolean

Type Parameters

T

The type of the property that changed.

Parameters

field
T

The field storing the property's value.

newValue
T

The property's value after the change occurred.

broadcast
Boolean

If true, Broadcast<T>(T, T, String) will also be invoked.

propertyName
String

(optional) The name of the property that changed.

Returns

true if the property was changed, false otherwise.

Remarks

This method is just like SetProperty<T>(T, T, String), just with the addition of the broadcast parameter. As such, following the behavior of the base method, the PropertyChanging and PropertyChanged events are not raised if the current and new value for the target property are the same.

Applies to

SetProperty<T>(T, T, Action<T>, Boolean, String)

Compares the current and new values for a given property. If the value has changed, raises the PropertyChanging event, updates the property with the new value, then raises the PropertyChanged event. Similarly to the SetProperty<T>(T, T, Action<T>, String) method, this overload should only be used when SetProperty<T>(T, T, String) can't be used directly.

protected bool SetProperty<T> (T oldValue, T newValue, Action<T> callback, bool broadcast, string? propertyName = default);
override this.SetProperty : 'T * 'T * Action<'T> * bool * string -> bool
Protected Function SetProperty(Of T) (oldValue As T, newValue As T, callback As Action(Of T), broadcast As Boolean, Optional propertyName As String = Nothing) As Boolean

Type Parameters

T

The type of the property that changed.

Parameters

oldValue
T

The current property value.

newValue
T

The property's value after the change occurred.

callback
Action<T>

A callback to invoke to update the property value.

broadcast
Boolean

If true, Broadcast<T>(T, T, String) will also be invoked.

propertyName
String

(optional) The name of the property that changed.

Returns

true if the property was changed, false otherwise.

Remarks

This method is just like SetProperty<T>(T, T, Action<T>, String), just with the addition of the broadcast parameter. As such, following the behavior of the base method, the PropertyChanging and PropertyChanged events are not raised if the current and new value for the target property are the same.

Applies to

SetProperty<T>(T, T, IEqualityComparer<T>, Boolean, String)

Compares the current and new values for a given property. If the value has changed, raises the PropertyChanging event, updates the property with the new value, then raises the PropertyChanged event. See additional notes about this overload in SetProperty<T>(T, T, Boolean, String).

protected bool SetProperty<T> (ref T field, T newValue, System.Collections.Generic.IEqualityComparer<T> comparer, bool broadcast, string? propertyName = default);
override this.SetProperty : 'T * 'T * System.Collections.Generic.IEqualityComparer<'T> * bool * string -> bool
Protected Function SetProperty(Of T) (ByRef field As T, newValue As T, comparer As IEqualityComparer(Of T), broadcast As Boolean, Optional propertyName As String = Nothing) As Boolean

Type Parameters

T

The type of the property that changed.

Parameters

field
T

The field storing the property's value.

newValue
T

The property's value after the change occurred.

comparer
IEqualityComparer<T>

The IEqualityComparer<T> instance to use to compare the input values.

broadcast
Boolean

If true, Broadcast<T>(T, T, String) will also be invoked.

propertyName
String

(optional) The name of the property that changed.

Returns

true if the property was changed, false otherwise.

Applies to

SetProperty<T>(T, T, IEqualityComparer<T>, Action<T>, Boolean, String)

Compares the current and new values for a given property. If the value has changed, raises the PropertyChanging event, updates the property with the new value, then raises the PropertyChanged event. See additional notes about this overload in SetProperty<T>(T, T, Action<T>, Boolean, String).

protected bool SetProperty<T> (T oldValue, T newValue, System.Collections.Generic.IEqualityComparer<T> comparer, Action<T> callback, bool broadcast, string? propertyName = default);
override this.SetProperty : 'T * 'T * System.Collections.Generic.IEqualityComparer<'T> * Action<'T> * bool * string -> bool
Protected Function SetProperty(Of T) (oldValue As T, newValue As T, comparer As IEqualityComparer(Of T), callback As Action(Of T), broadcast As Boolean, Optional propertyName As String = Nothing) As Boolean

Type Parameters

T

The type of the property that changed.

Parameters

oldValue
T

The current property value.

newValue
T

The property's value after the change occurred.

comparer
IEqualityComparer<T>

The IEqualityComparer<T> instance to use to compare the input values.

callback
Action<T>

A callback to invoke to update the property value.

broadcast
Boolean

If true, Broadcast<T>(T, T, String) will also be invoked.

propertyName
String

(optional) The name of the property that changed.

Returns

true if the property was changed, false otherwise.

Applies to

SetProperty<TModel,T>(T, T, TModel, Action<TModel,T>, Boolean, String)

Compares the current and new values for a given nested property. If the value has changed, raises the PropertyChanging event, updates the property and then raises the PropertyChanged event. The behavior mirrors that of SetProperty<TModel,T>(T, T, TModel, Action<TModel,T>, String), with the difference being that this method is used to relay properties from a wrapped model in the current instance. For more info, see the docs for SetProperty<TModel,T>(T, T, TModel, Action<TModel,T>, String).

protected bool SetProperty<TModel,T> (T oldValue, T newValue, TModel model, Action<TModel,T> callback, bool broadcast, string? propertyName = default) where TModel : class;
override this.SetProperty : 'T * 'T * 'Model * Action<'Model, 'T (requires 'Model : null)> * bool * string -> bool (requires 'Model : null)
Protected Function SetProperty(Of TModel As Class, T As Class) (oldValue As T, newValue As T, model As TModel, callback As Action(Of TModel, T), broadcast As Boolean, Optional propertyName As String = Nothing) As Boolean

Type Parameters

TModel

The type of model whose property (or field) to set.

T

The type of property (or field) to set.

Parameters

oldValue
T

The current property value.

newValue
T

The property's value after the change occurred.

model
TModel

The model

callback
Action<TModel,T>

The callback to invoke to set the target property value, if a change has occurred.

broadcast
Boolean

If true, Broadcast<T>(T, T, String) will also be invoked.

propertyName
String

(optional) The name of the property that changed.

Returns

true if the property was changed, false otherwise.

Applies to

SetProperty<TModel,T>(T, T, IEqualityComparer<T>, TModel, Action<TModel,T>, Boolean, String)

Compares the current and new values for a given nested property. If the value has changed, raises the PropertyChanging event, updates the property and then raises the PropertyChanged event. The behavior mirrors that of SetProperty<TModel,T>(T, T, IEqualityComparer<T>, TModel, Action<TModel,T>, String), with the difference being that this method is used to relay properties from a wrapped model in the current instance. For more info, see the docs for SetProperty<TModel,T>(T, T, IEqualityComparer<T>, TModel, Action<TModel,T>, String).

protected bool SetProperty<TModel,T> (T oldValue, T newValue, System.Collections.Generic.IEqualityComparer<T> comparer, TModel model, Action<TModel,T> callback, bool broadcast, string? propertyName = default) where TModel : class;
override this.SetProperty : 'T * 'T * System.Collections.Generic.IEqualityComparer<'T> * 'Model * Action<'Model, 'T (requires 'Model : null)> * bool * string -> bool (requires 'Model : null)
Protected Function SetProperty(Of TModel As Class, T As Class) (oldValue As T, newValue As T, comparer As IEqualityComparer(Of T), model As TModel, callback As Action(Of TModel, T), broadcast As Boolean, Optional propertyName As String = Nothing) As Boolean

Type Parameters

TModel

The type of model whose property (or field) to set.

T

The type of property (or field) to set.

Parameters

oldValue
T

The current property value.

newValue
T

The property's value after the change occurred.

comparer
IEqualityComparer<T>

The IEqualityComparer<T> instance to use to compare the input values.

model
TModel

The model

callback
Action<TModel,T>

The callback to invoke to set the target property value, if a change has occurred.

broadcast
Boolean

If true, Broadcast<T>(T, T, String) will also be invoked.

propertyName
String

(optional) The name of the property that changed.

Returns

true if the property was changed, false otherwise.

Applies to