)} ,System.String)} ,System.Action{System.EventHandler{--1}},System.Action{System.EventHandler{--1}})} ,System.Action{System.EventHandler},System.Action{System.EventHandler})}
CreatesWinformsCommandBinding.BindCommandToObject(ICommand?, T?, IObservable
Defined in
Type: CreatesWinformsCommandBinding
Namespace: ReactiveUI.Winforms
Assembly: ReactiveUI.Winforms.dll
Applies to
net10.0-windows10.0.19041, net9.0-windows10.0.19041, net8.0-windows10.0.19041, net462, net481
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¶
public IDisposable? BindCommandToObject<T>(ICommand? command, T? target, IObservable<object?> commandParameter) where T : class
Summary: Binds a command to the default event on a Windows Forms control. This method uses direct type checking and the AOT-safe add/remove handler overload instead of reflection.
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, or null if no default event was found.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when target is null. |
2. Overload¶
public IDisposable? BindCommandToObject<T, TEventArgs>(ICommand? command, T? target, IObservable<object?> commandParameter, string eventName) where T : class
Inherited documentation
These docs were inherited from ICreatesCommandBinding. The member doesn't override them on this type.
Summary: Bind an ICommand to a UI object to a specific event. This event may be a standard .NET event, or it could be an event derived in another manner (i.e. in MonoTouch). This method is fully AOT-compatible as it uses generic type parameters instead of reflection.
Type parameters
| Name | Description |
|---|---|
T | The type of the target object to which the command is bound. Must be a reference type. |
TEventArgs | The event argument type. |
Parameters
| Name | Type | Description |
|---|---|---|
command | ICommand? | The command to bind. Can be null. |
target | T? | The target object, usually a UI control of some kind. Can be null. |
commandParameter | IObservable | An IObservable source whose latest value will be passed as the command parameter to the command. Hosts will always pass a valid IObservable, but this may be Observable.Empty. |
eventName | string | The event to bind to. |
Returns: IDisposable? -- An IDisposable which will disconnect the binding when disposed, or null if no binding was created.
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 an event on a target object using explicit add/remove handler delegates. This overload is AOT-safe and doesn't require reflection.
Type parameters
| Name | Description |
|---|---|
T | The type of the target object. |
TEventArgs | The type of the event arguments. |
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 | Action that subscribes an event handler to the target event. |
removeHandler | Action | Action that unsubscribes an event 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 on a target object using explicit add/remove handler delegates for non-generic EventHandler.
This overload is AOT-safe and supports WinForms controls that use EventHandler instead of EventHandler
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. |
addHandler | Action | Action that subscribes an event handler to the target event. |
removeHandler | Action | Action that unsubscribes an event 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. |