},System.Linq.Expressions.Expression{System.Func{--0,--3}},System.Linq.Expressions.Expression{System.Func{--1,--4}},System.String)} },System.Linq.Expressions.Expression{System.Func{--0,--3}},System.Linq.Expressions.Expression{System.Func{--1,--4}})} },System.Linq.Expressions.Expression{System.Func{--0,--3}},System.IObservable{--4},System.String)} },System.Linq.Expressions.Expression{System.Func{--0,--3}},System.IObservable{--4})}
CommandBinderImplementation.BindCommand(TViewModel?, TView, Expression>, Expression>, Expression>, string?) method¶
Defined in
Type: CommandBinderImplementation
Namespace: ReactiveUI.Reactive
Assembly: ReactiveUI.Reactive.dll
Applies to
net10.0, net10.0-maccatalyst26.0, net10.0-desktop1.0, net10.0-browserwasm1.0, net10.0-tvos26.0, net10.0-windows10.0.19041, net10.0-macos26.0, net10.0-ios26.0, net10.0-android36.0, net9.0, net9.0-tvos18.0, net9.0-macos15.0, net9.0-maccatalyst18.0, net9.0-windows10.0.19041, net9.0-ios18.0, net9.0-desktop1.0, net8.0, net8.0-windows10.0.19041, net8.0-ios18.0, net8.0-maccatalyst18.0, net8.0-macos15.0, net8.0-tvos18.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.5, netstandard2.1, net481, net462, net471
Overloads¶
- 1.
public IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel? viewModel, TView view, Expression<Func<TViewModel, TProp?>> viewModelProperty, Expression<Func<TView, TControl>> controlProperty, Expression<Func<TViewModel, TParam?>> withParameter, string? toEvent) where TView : class, IViewFor where TViewModel : class where TProp : ICommand where TControl : class - 2.
public IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel? viewModel, TView view, Expression<Func<TViewModel, TProp?>> viewModelProperty, Expression<Func<TView, TControl>> controlProperty, Expression<Func<TViewModel, TParam?>> withParameter) where TView : class, IViewFor where TViewModel : class where TProp : ICommand where TControl : class - 3.
public IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel? viewModel, TView view, Expression<Func<TViewModel, TProp?>> viewModelProperty, Expression<Func<TView, TControl>> controlProperty, IObservable<TParam?> withParameter, string? toEvent) where TView : class, IViewFor where TViewModel : class where TProp : ICommand where TControl : class - 4.
public IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel? viewModel, TView view, Expression<Func<TViewModel, TProp?>> viewModelProperty, Expression<Func<TView, TControl>> controlProperty, IObservable<TParam?> withParameter) where TView : class, IViewFor where TViewModel : class where TProp : ICommand where TControl : class
1. Overload¶
Attributes: [RequiresUnreferencedCode("Dynamic observation uses reflection over members that may be trimmed.")]
public IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel? viewModel, TView view, Expression<Func<TViewModel, TProp?>> viewModelProperty, Expression<Func<TView, TControl>> controlProperty, Expression<Func<TViewModel, TParam?>> withParameter, string? toEvent) where TView : class, IViewFor where TViewModel : class where TProp : ICommand where TControl : class
Summary: Binds a command from the view model to a control on the view, enabling the control to execute the command with an optional parameter when triggered by a specified event.
Type parameters
| Name | Description |
|---|---|
TView | The type of the view implementing the IViewFor interface. |
TViewModel | The type of the view model containing the command property. |
TProp | The type of the command property to bind, implementing ICommand. |
TControl | The type of the control on the view to which the command will be bound. |
TParam | The type of the parameter passed to the command when it is executed. |
Parameters
| Name | Type | Description |
|---|---|---|
viewModel | TViewModel? | The view model instance containing the command to bind. Can be null if the binding should be established without an initial view model. |
view | TView | The view instance containing the control to which the command will be bound. Cannot be null. |
viewModelProperty | Expression | An expression specifying the command property on the view model to bind. Cannot be null. |
controlProperty | Expression | An expression specifying the control on the view to which the command will be bound. Cannot be null. |
withParameter | Expression | An expression specifying the parameter to pass to the command when it is executed. Can be null if the command does not require a parameter. |
toEvent | string? | The name of the event on the control that triggers the command execution. If null, a default event is used based on the control type. |
Returns: IReactiveBinding
Remarks
This method uses reflection to observe properties and events, which may be affected by trimming in some deployment scenarios. The binding is one-way, from the view model command to the view control. If the specified event is not found on the control, an exception may be thrown at runtime.
2. Overload¶
Attributes: [RequiresUnreferencedCode("Dynamic observation uses reflection over members that may be trimmed.")]
public IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel? viewModel, TView view, Expression<Func<TViewModel, TProp?>> viewModelProperty, Expression<Func<TView, TControl>> controlProperty, Expression<Func<TViewModel, TParam?>> withParameter) where TView : class, IViewFor where TViewModel : class where TProp : ICommand where TControl : class
Summary: Binds a command from the view model to a control on the view, enabling the control to execute the command with a parameter using the default event for the control type.
Type parameters
| Name | Description |
|---|---|
TView | The type of the view implementing the IViewFor interface. |
TViewModel | The type of the view model containing the command property. |
TProp | The type of the command property to bind, implementing ICommand. |
TControl | The type of the control on the view to which the command will be bound. |
TParam | The type of the parameter passed to the command when it is executed. |
Parameters
| Name | Type | Description |
|---|---|---|
viewModel | TViewModel? | The view model instance containing the command to bind. Can be null if the binding should be established without an initial view model. |
view | TView | The view instance containing the control to which the command will be bound. Cannot be null. |
viewModelProperty | Expression | An expression specifying the command property on the view model to bind. Cannot be null. |
controlProperty | Expression | An expression specifying the control on the view to which the command will be bound. Cannot be null. |
withParameter | Expression | An expression specifying the parameter to pass to the command when it is executed. Can be null if the command does not require a parameter. |
Returns: IReactiveBinding
Remarks
This method uses reflection to observe properties and events, which may be affected by trimming in some deployment scenarios. The binding is one-way, from the view model command to the view control.
3. Overload¶
Attributes: [RequiresUnreferencedCode("Dynamic observation uses reflection over members that may be trimmed.")]
public IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel? viewModel, TView view, Expression<Func<TViewModel, TProp?>> viewModelProperty, Expression<Func<TView, TControl>> controlProperty, IObservable<TParam?> withParameter, string? toEvent) where TView : class, IViewFor where TViewModel : class where TProp : ICommand where TControl : class
Summary: Binds a command from the view model to a control on the view, enabling the control to execute the command with an optional parameter stream and event trigger.
Type parameters
| Name | Description |
|---|---|
TView | The type of the view implementing the IViewFor interface. |
TViewModel | The type of the view model containing the command property. |
TProp | The type of the command property, which must implement ICommand. |
TControl | The type of the control on the view to which the command will be bound. |
TParam | The type of the parameter passed to the command when it is executed. |
Parameters
| Name | Type | Description |
|---|---|---|
viewModel | TViewModel? | The view model instance containing the command to bind. Can be null if the view model is not available at binding time. |
view | TView | The view instance containing the control to which the command will be bound. |
viewModelProperty | Expression | An expression specifying the command property on the view model to bind. |
controlProperty | Expression | An expression specifying the control on the view that will trigger the command. |
withParameter | IObservable | An observable sequence providing the parameter to pass to the command when it is executed. The latest value is used for each command invocation. |
toEvent | string? | The name of the event on the control that triggers the command. If null, a default event is used based on the control type. |
Returns: IReactiveBinding
Remarks
This method uses reflection to observe and bind to members, which may be affected by trimming in some environments. The binding is one-way, from the view model command to the view control. If the control or command property is not found, the binding will not be established. The method is suitable for scenarios where commands need to be dynamically bound to controls with support for parameter streams and custom event triggers.
4. Overload¶
Attributes: [RequiresUnreferencedCode("Dynamic observation uses reflection over members that may be trimmed.")]
public IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel? viewModel, TView view, Expression<Func<TViewModel, TProp?>> viewModelProperty, Expression<Func<TView, TControl>> controlProperty, IObservable<TParam?> withParameter) where TView : class, IViewFor where TViewModel : class where TProp : ICommand where TControl : class
Summary: Binds a command from the view model to a control on the view, enabling the control to execute the command with an parameter stream using the default event for the control type.
Type parameters
| Name | Description |
|---|---|
TView | The type of the view implementing the IViewFor interface. |
TViewModel | The type of the view model containing the command property. |
TProp | The type of the command property, which must implement ICommand. |
TControl | The type of the control on the view to which the command will be bound. |
TParam | The type of the parameter passed to the command when it is executed. |
Parameters
| Name | Type | Description |
|---|---|---|
viewModel | TViewModel? | The view model instance containing the command to bind. Can be null if the view model is not available at binding time. |
view | TView | The view instance containing the control to which the command will be bound. |
viewModelProperty | Expression | An expression specifying the command property on the view model to bind. |
controlProperty | Expression | An expression specifying the control on the view that will trigger the command. |
withParameter | IObservable | An observable sequence providing the parameter to pass to the command when it is executed. The latest value is used for each command invocation. |
Returns: IReactiveBinding
Remarks
This method uses reflection to observe and bind to members, which may be affected by trimming in some environments. The binding is one-way, from the view model command to the view control. If the control or command property is not found, the binding will not be established.