)} ,System.String)} ,System.Action{System.EventHandler{--1}},System.Action{System.EventHandler{--1}})}
ICreatesCommandBinding.BindCommandToObject(ICommand?, T?, IObservable
Defined in
Type: ICreatesCommandBinding
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.
IDisposable? BindCommandToObject<T>(ICommand? command, T? target, IObservable<object?> commandParameter) where T : class - 2.
IDisposable? BindCommandToObject<T, TEventArgs>(ICommand? command, T? target, IObservable<object?> commandParameter, string eventName) where T : class - 3.
IDisposable? BindCommandToObject<T, TEventArgs>(ICommand? command, T? target, IObservable<object?> commandParameter, Action<EventHandler<TEventArgs>> addHandler, Action<EventHandler<TEventArgs>> removeHandler) where T : class where TEventArgs : EventArgs
1. Overload¶
Attributes: [RequiresUnreferencedCode("String/reflection-based event binding may require members removed by trimming.")]
IDisposable? BindCommandToObject<T>(ICommand? command, T? target, IObservable<object?> commandParameter) where T : class
Summary: Binds an ICommand to a UI object using the default event. The default event is determined by the implementation (e.g., Click, TouchUpInside).
Type parameters
| Name | Description |
|---|---|
T | The type of the target object. |
Parameters
| Name | Type | Description |
|---|---|---|
command | ICommand? | The command to bind. If null, no binding is created. |
target | T? | The target object, usually a UI control. |
commandParameter | IObservable | An observable that provides the command parameter value. |
Returns: IDisposable? -- An IDisposable that disconnects the binding when disposed, or null if no binding was created.
2. Overload¶
Attributes: [RequiresUnreferencedCode("String/reflection-based event binding may require members removed by trimming.")]
IDisposable? BindCommandToObject<T, TEventArgs>(ICommand? command, T? target, IObservable<object?> commandParameter, string eventName) where T : class
Summary: Binds an ICommand to a UI object to a specific named event.
Type parameters
| Name | Description |
|---|---|
T | The type of the target object. |
TEventArgs | The event argument type. |
Parameters
| Name | Type | Description |
|---|---|---|
command | ICommand? | The command to bind. If null, no binding is created. |
target | T? | The target object, usually a UI control. |
commandParameter | IObservable | An observable that provides the command parameter value. |
eventName | string | The event to bind to. |
Returns: IDisposable? -- An IDisposable that disconnects the binding when disposed, or null if no binding was created.
3. Overload¶
IDisposable? BindCommandToObject<T, TEventArgs>(ICommand? command, T? target, IObservable<object?> commandParameter, Action<EventHandler<TEventArgs>> addHandler, Action<EventHandler<TEventArgs>> removeHandler) where T : class where TEventArgs : EventArgs
Summary: Binds a command to a specific event on a target object using explicit add/remove handler delegates. This overload is fully AOT-compatible as it avoids reflection-based event lookup.
Type parameters
| Name | Description |
|---|---|
T | The type of the target object. |
TEventArgs | The event arguments type. |
Parameters
| Name | Type | Description |
|---|---|---|
command | ICommand? | The command to bind. If null, no binding is created. |
target | T? | The target object. |
commandParameter | IObservable | An observable that supplies command parameter values. |
addHandler | Action | Adds the handler to the target event. |
removeHandler | Action | Removes the handler from the target event. |
Returns: IDisposable? -- A disposable that unbinds the command.