Skip to content

Applies to

net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-tvos18.0, net9.0-maccatalyst18.0, net9.0-ios18.0, net9.0-macos15.0, net9.0-desktop1.0, net8.0, net8.0-macos14.5, net8.0-ios18.0, net8.0-maccatalyst18.0, net8.0-macos15.0, net8.0-tvos18.0, net8.0-ios17.5, net8.0-maccatalyst17.5, netstandard2.1, net481, net462, net471

Attributes: [RequiresUnreferencedCode("Runtime command binding resolves the property chain by reflection.")]

public static IDisposable BindCommand<TView, TViewModel, TProp, TControl>(TView view, TViewModel? viewModel, Expression<Func<TViewModel, TProp?>> commandProperty, Expression<Func<TView, TControl>> controlProperty, IObservable<object?> commandParameter, string? toEvent, string bindingExpression) where TView : class where TViewModel : class where TProp : ICommand where TControl : class

View source

Summary: Keeps the command an observed property holds bound to the control another one holds.

Type parameters

NameDescription
TViewThe type declaring the control property.
TViewModelThe type declaring the command property.
TPropThe type of the command property.
TControlThe type of the control the command is bound to.

Parameters

NameTypeDescription
viewTViewThe object declaring the control property.
viewModelTViewModel?The object declaring the command property.
commandPropertyExpression>The property holding the command to bind.
controlPropertyExpression>The property holding the control to bind it to.
commandParameterIObservableThe values offered as the command parameter.
toEventstring?The control event that executes the command, or null for the control's default.
bindingExpressionstringThe bound expression, named when the observation faults.

Returns: IDisposable -- A disposable that, when disposed, unbinds the command and stops observing.

Exceptions

TypeCondition
System.ArgumentNullExceptioncommandProperty or controlProperty is null.