CommandBindingsCollectionAddTEventArgs, TTarget, TParam(ActionICommandSourceTEventArgs, ICommandState, TTarget, TParam, FuncTParam, IDictionaryString, Object) Method

Creates a binding with an internally created disposable SourceAwareTargetedCommandTEventArgs, TTarget, TParam for the specified callback without any sources and targets. At least one source must be added by the ICommandBinding.AddSource method to make the command invokable. Targets can be added by the ICommandBinding.AddTarget method. The created binding will be added to this CommandBindingsCollection.

Definition

Namespace: KGySoft.ComponentModel
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.1.0
C#
public ICommandBinding Add<TEventArgs, TTarget, TParam>(
	Action<ICommandSource<TEventArgs>, ICommandState, TTarget, TParam> callback,
	Func<TParam> getParam,
	IDictionary<string, Object?>? initialState = null
)
where TEventArgs : EventArgs

Parameters

callback  ActionICommandSourceTEventArgs, ICommandState, TTarget, TParam
The delegate to create the command from.
getParam  FuncTParam
The delegate that returns the command parameter value for the callback delegate when the command is executed.
initialState  IDictionaryString, Object  (Optional)
The initial state of the binding. This parameter is optional.
Default value: .

Type Parameters

TEventArgs
The type of the event argument of the source events.
TTarget
The type of the targets of the command binding.
TParam
The type of the command parameter.

Return Value

ICommandBinding
An ICommandBinding instance, whose State is initialized by the provided initialState. To make the command invokable by this binding, at least one source must be added by the AddSource method on the result. Targets can be added by the AddTarget method on the result.

See Also