다음을 통해 공유


NotifyPropertyChangedObject.SetProperty<T>(T, T, String) Method

Definition

Sets the value of a property's backing field and raises PropertyChanged.

If the value of storage is already the same as value, storage is not updated and PropertyChanged is not raised. This comparison is performed with the default EqualityComparer<T> when T is a value types or a string, with ReferenceEquals(Object, Object) otherwise.

This method should be called from inside a property setter.

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

Type Parameters

T

The type of the property being set.

Parameters

storage
T

The backing field for the property being set.

value
T

The new value to assign to storage.

propertyName
String

The name of the property being set to be used when raising PropertyChanged.

This parameter should be onitted value when this method is called from a property's setter.

Returns

Whether storage was updated and PropertyChanged raised.

Applies to