CommandCreateTwoWayPropertyBinding(INotifyPropertyChanged, String, INotifyPropertyChanged, String, FuncObject, Object, FuncObject, Object) Method

Creates a pair of special bindings for the PropertyChanged event of the specified source and target, which allow to update the specified targetPropertyName and sourcePropertyName in both directions when any of them changes.

Definition

Namespace: KGySoft.ComponentModel
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0
C#
public static ICommandBinding[] CreateTwoWayPropertyBinding(
	this INotifyPropertyChanged source,
	string sourcePropertyName,
	INotifyPropertyChanged target,
	string? targetPropertyName = null,
	Func<Object?, Object?>? format = null,
	Func<Object?, Object?>? parse = null
)

Parameters

source  INotifyPropertyChanged
The source object, whose property specified by the sourcePropertyName parameter is observed.
sourcePropertyName  String
The name of the source property, whose change is observed.
target  INotifyPropertyChanged
The target object, whose property specified by the targetPropertyName parameter is observed.
targetPropertyName  String  (Optional)
The name of the target property, whose change is observed. If , then it is considered as the same as sourcePropertyName. This parameter is optional.
Default value: .
format  FuncObject, Object  (Optional)
If not , then can be used to format the value to be set in the target object. This parameter is optional.
Default value: .
parse  FuncObject, Object  (Optional)
If not , then can be used to parse the value to be set in the source object. This parameter is optional.
Default value: .

Return Value

ICommandBinding
The created pair of ICommandBinding instances.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type INotifyPropertyChanged. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

ArgumentNullExceptionsource, sourcePropertyName or target is .
ArgumentExceptionsource or target is neither an INotifyPropertyChanged implementation nor has a sourcePropertyNameChanged event.

See Also