)} ,System.String)} ,System.Action{System.EventHandler{--1}},System.Action{System.EventHandler{--1}})} ,System.Action{System.EventHandler},System.Action{System.EventHandler})}
CreatesCommandBindingViaEvent.BindCommandToObject(ICommand?, T?, IObservable
Defined in
Type: CreatesCommandBindingViaEvent
Namespace: ReactiveUI
Assembly: ReactiveUI.dll
Applies to
net10.0, net10.0-android36.0, net10.0-ios26.0, net10.0-macos26.0, net10.0-windows10.0.19041, net10.0-tvos26.0, net10.0-maccatalyst26.0, net10.0-desktop1.0, net10.0-browserwasm1.0, net9.0, net9.0-tvos18.0, net9.0-maccatalyst18.0, net9.0-windows10.0.19041, net9.0-desktop1.0, net9.0-browserwasm1.0, net9.0-macos15.0, net9.0-ios18.0, net9.0-android35.0, net8.0, net8.0-macos14.5, net8.0-macos14.2, net8.0-maccatalyst17.5, net8.0-ios17.5, net8.0-tvos18.0, net8.0-macos15.0, net8.0-ios18.0, net8.0-windows10.0.19041, net8.0-maccatalyst18.0, net8.0-tvos17.2, netstandard2.1, net481, net462
Overloads¶
- 1.
public IDisposable? BindCommandToObject<T>(ICommand? command, T? target, IObservable<object?> commandParameter) where T : class - 2.
public IDisposable? BindCommandToObject<T, TEventArgs>(ICommand? command, T? target, IObservable<object?> commandParameter, string eventName) where T : class - 3.
public 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 - 4.
public IDisposable BindCommandToObject<T>(ICommand? command, T? target, IObservable<object?> commandParameter, Action<EventHandler> addHandler, Action<EventHandler> removeHandler) where T : class
1. Overload¶
Attributes: [RequiresUnreferencedCode("String/reflection-based event binding may require members removed by trimming.")]
public IDisposable? BindCommandToObject<T>(ICommand? command, T? target, IObservable<object?> commandParameter) where T : class
Summary: Binds a command to the default event on a target object using a generic type parameter.
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. |
commandParameter | IObservable | An observable that supplies command parameter values. |
Returns: IDisposable? -- A disposable that unbinds the command.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when target is null. |
| System.Exception | Thrown when no default event exists on T and the caller did not specify an event explicitly. |
2. Overload¶
Attributes: [RequiresUnreferencedCode("String/reflection-based event binding may require members removed by trimming.")]
public IDisposable? BindCommandToObject<T, TEventArgs>(ICommand? command, T? target, IObservable<object?> commandParameter, string eventName) where T : class
Summary: Binds a command to a specific event on a target object using generic type parameters.
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. |
eventName | string | The name of the event to bind to. |
Returns: IDisposable? -- A disposable that unbinds the command.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when target or eventName is null. |
| System.ArgumentException | Thrown when eventName is empty. |
3. Overload¶
public 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.
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.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when target, addHandler, or removeHandler is null. |
4. Overload¶
public IDisposable BindCommandToObject<T>(ICommand? command, T? target, IObservable<object?> commandParameter, Action<EventHandler> addHandler, Action<EventHandler> removeHandler) where T : class
Summary: Binds a command to an event using explicit add/remove handler actions (non-reflection).
Type parameters
| Name | Description |
|---|---|
T | The target 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.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when target, addHandler, or removeHandler is null. |