Skip to content

},System.Linq.Expressions.Expression{System.Func{--0,--3}},System.String,System.String,System.String,System.String,System.Int32)} },System.Linq.Expressions.Expression{System.Func{--0,--3}},System.IObservable{--4},System.String,System.String,System.String,System.String,System.Int32)} },System.Linq.Expressions.Expression{System.Func{--0,--3}},System.Linq.Expressions.Expression{System.Func{--1,--4}},System.String,System.String,System.String,System.String,System.String,System.Int32)}

ReactiveUIBindingExtensions.BindCommand(TView, TViewModel?, Expression>, Expression>, string?, string, string, string, int) method

Defined in

Type: ReactiveUIBindingExtensions Namespace: ReactiveUI.Binding Assembly: ReactiveUI.Binding.dll

Applies to

net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481

Overloads

  • 1. public static IDisposable BindCommand<TView, TViewModel, TProp, TControl>(this TView view, TViewModel? viewModel, Expression<Func<TViewModel, TProp?>> propertyName, Expression<Func<TView, TControl>> controlName, string? toEvent = null, string propertyNameExpression = "", string controlNameExpression = "", string callerFilePath = "", int callerLineNumber = 0) where TView : class, IViewFor where TViewModel : class where TProp : ICommand where TControl : class
  • 2. public static IDisposable BindCommand<TView, TViewModel, TProp, TControl, TParam>(this TView view, TViewModel? viewModel, Expression<Func<TViewModel, TProp?>> propertyName, Expression<Func<TView, TControl>> controlName, IObservable<TParam?> withParameter, string? toEvent = null, string propertyNameExpression = "", string controlNameExpression = "", string callerFilePath = "", int callerLineNumber = 0) where TView : class, IViewFor where TViewModel : class where TProp : ICommand where TControl : class
  • 3. public static IDisposable BindCommand<TView, TViewModel, TProp, TControl, TParam>(this TView view, TViewModel? viewModel, Expression<Func<TViewModel, TProp?>> propertyName, Expression<Func<TView, TControl>> controlName, Expression<Func<TViewModel, TParam?>> withParameter, string? toEvent = null, string propertyNameExpression = "", string controlNameExpression = "", string withParameterExpression = "", string callerFilePath = "", int callerLineNumber = 0) where TView : class, IViewFor where TViewModel : class where TProp : ICommand where TControl : class

1. Overload

public static IDisposable BindCommand<TView, TViewModel, TProp, TControl>(this TView view, TViewModel? viewModel, Expression<Func<TViewModel, TProp?>> propertyName, Expression<Func<TView, TControl>> controlName, string? toEvent = null, string propertyNameExpression = "", string controlNameExpression = "", string callerFilePath = "", int callerLineNumber = 0) where TView : class, IViewFor where TViewModel : class where TProp : ICommand where TControl : class

View source

Summary: Binds a command from a view model to a control on a view.

Type parameters

NameDescription
TViewThe type of the view.
TViewModelThe type of the view model.
TPropThe type of the command property.
TControlThe type of the control.

Parameters

NameTypeDescription
viewTViewThe view to bind to.
viewModelTViewModel?The view model containing the command.
propertyNameExpression>An expression that selects the command property on the view model.
controlNameExpression>An expression that selects the control on the view.
toEvent = nullstring?The event name to bind to. If null, a default event is selected.
propertyNameExpression = ""stringThe caller argument expression for propertyName. Auto-populated by the compiler.
controlNameExpression = ""stringThe caller argument expression for controlName. Auto-populated by the compiler.
callerFilePath = ""stringThe source file path of the caller. Auto-populated by the compiler.
callerLineNumber = 0intThe source line number of the caller. Auto-populated by the compiler.

Returns: IDisposable -- A disposable that, when disposed, disconnects the binding.

2. Overload

public static IDisposable BindCommand<TView, TViewModel, TProp, TControl, TParam>(this TView view, TViewModel? viewModel, Expression<Func<TViewModel, TProp?>> propertyName, Expression<Func<TView, TControl>> controlName, IObservable<TParam?> withParameter, string? toEvent = null, string propertyNameExpression = "", string controlNameExpression = "", string callerFilePath = "", int callerLineNumber = 0) where TView : class, IViewFor where TViewModel : class where TProp : ICommand where TControl : class

View source

Summary: Binds a command from a view model to a control on a view with an observable parameter.

Type parameters

NameDescription
TViewThe type of the view.
TViewModelThe type of the view model.
TPropThe type of the command property.
TControlThe type of the control.
TParamThe type of the command parameter.

Parameters

NameTypeDescription
viewTViewThe view to bind to.
viewModelTViewModel?The view model containing the command.
propertyNameExpression>An expression that selects the command property on the view model.
controlNameExpression>An expression that selects the control on the view.
withParameterIObservableAn observable that provides the command parameter.
toEvent = nullstring?The event name to bind to. If null, a default event is selected.
propertyNameExpression = ""stringThe caller argument expression for propertyName. Auto-populated by the compiler.
controlNameExpression = ""stringThe caller argument expression for controlName. Auto-populated by the compiler.
callerFilePath = ""stringThe source file path of the caller. Auto-populated by the compiler.
callerLineNumber = 0intThe source line number of the caller. Auto-populated by the compiler.

Returns: IDisposable -- A disposable that, when disposed, disconnects the binding.

3. Overload

public static IDisposable BindCommand<TView, TViewModel, TProp, TControl, TParam>(this TView view, TViewModel? viewModel, Expression<Func<TViewModel, TProp?>> propertyName, Expression<Func<TView, TControl>> controlName, Expression<Func<TViewModel, TParam?>> withParameter, string? toEvent = null, string propertyNameExpression = "", string controlNameExpression = "", string withParameterExpression = "", string callerFilePath = "", int callerLineNumber = 0) where TView : class, IViewFor where TViewModel : class where TProp : ICommand where TControl : class

View source

Summary: Binds a command from a view model to a control on a view with a parameter expression.

Type parameters

NameDescription
TViewThe type of the view.
TViewModelThe type of the view model.
TPropThe type of the command property.
TControlThe type of the control.
TParamThe type of the command parameter.

Parameters

NameTypeDescription
viewTViewThe view to bind to.
viewModelTViewModel?The view model containing the command.
propertyNameExpression>An expression that selects the command property on the view model.
controlNameExpression>An expression that selects the control on the view.
withParameterExpression>An expression that selects the command parameter property on the view model.
toEvent = nullstring?The event name to bind to. If null, a default event is selected.
propertyNameExpression = ""stringThe caller argument expression for propertyName. Auto-populated by the compiler.
controlNameExpression = ""stringThe caller argument expression for controlName. Auto-populated by the compiler.
withParameterExpression = ""stringThe caller argument expression for withParameter. Auto-populated by the compiler.
callerFilePath = ""stringThe source file path of the caller. Auto-populated by the compiler.
callerLineNumber = 0intThe source line number of the caller. Auto-populated by the compiler.

Returns: IDisposable -- A disposable that, when disposed, disconnects the binding.