,System.String,System.Reflection.PropertyInfo)} ,System.Action{System.EventHandler{--0}},System.Action{System.EventHandler{--0}},System.Action{System.Object,System.Object,System.Object[]})} ,System.Action{System.EventHandler},System.Action{System.EventHandler},System.Action{System.Object,System.Object,System.Object[]})}
FlexibleCommandBinder.ForEvent(ICommand?, object?, IObservable
Defined in
Type: FlexibleCommandBinder
Namespace: ReactiveUI.Reactive
Assembly: ReactiveUI.Reactive.dll
Applies to
net10.0-android36.0, net10.0-ios26.0, net10.0-maccatalyst26.0, net10.0-tvos26.0
Overloads¶
- 1.
protected static IDisposable ForEvent(ICommand? command, object? target, IObservable<object?> commandParameter, string eventName, PropertyInfo enabledProperty) - 2.
protected static IDisposable ForEvent<TEventArgs>(ICommand? command, object? target, IObservable<object?>? commandParameter, Action<EventHandler<TEventArgs>> addHandler, Action<EventHandler<TEventArgs>> removeHandler, Action<object?, object?, object?[]?>? enabledSetter) where TEventArgs : EventArgs - 3.
protected static IDisposable ForEvent(ICommand? command, object? target, IObservable<object?>? commandParameter, Action<EventHandler> addHandler, Action<EventHandler> removeHandler, Action<object?, object?, object?[]?>? enabledSetter)
1. Overload¶
Attributes: [RequiresUnreferencedCode("String/reflection-based event binding may require members removed by trimming.")]
protected static IDisposable ForEvent(ICommand? command, object? target, IObservable<object?> commandParameter, string eventName, PropertyInfo enabledProperty)
Summary: Creates a commands binding from event and a property.
Parameters
| Name | Type | Description |
|---|---|---|
command | ICommand? | Command. |
target | object? | Target. |
commandParameter | IObservable | Command parameter. |
eventName | string | Event name. |
enabledProperty | PropertyInfo | Enabled property name. |
Returns: IDisposable -- The binding from event.
2. Overload¶
protected static IDisposable ForEvent<TEventArgs>(ICommand? command, object? target, IObservable<object?>? commandParameter, Action<EventHandler<TEventArgs>> addHandler, Action<EventHandler<TEventArgs>> removeHandler, Action<object?, object?, object?[]?>? enabledSetter) where TEventArgs : EventArgs
Summary: Creates a command binding from an event using explicit add/remove handler delegates and optionally synchronizes an enabled property with CanExecute.
Type parameters
| Name | Description |
|---|---|
TEventArgs | The event arguments type. |
Parameters
| Name | Type | Description |
|---|---|---|
command | ICommand? | The command to bind. |
target | object? | The event source object. |
commandParameter | IObservable | Observable producing command parameter values. If null, target is used. |
addHandler | Action | Adds the handler to the event source. |
removeHandler | Action | Removes the handler from the event source. |
enabledSetter | Action | Optional setter for an enabled-like property. If null, enabled synchronization is skipped. The setter is expected to accept target as the first argument and a Boolean value as the second. |
Returns: IDisposable -- A disposable that unbinds the command and stops enabled synchronization.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when command is null. |
3. Overload¶
protected static IDisposable ForEvent(ICommand? command, object? target, IObservable<object?>? commandParameter, Action<EventHandler> addHandler, Action<EventHandler> removeHandler, Action<object?, object?, object?[]?>? enabledSetter)
Summary: Creates a command binding from an event using explicit add/remove handler delegates and optionally synchronizes an enabled property with CanExecute.
Parameters
| Name | Type | Description |
|---|---|---|
command | ICommand? | The command to bind. |
target | object? | The event source object. |
commandParameter | IObservable | Observable producing command parameter values. If null, target is used. |
addHandler | Action | Adds the handler to the event source. |
removeHandler | Action | Removes the handler from the event source. |
enabledSetter | Action | Optional setter for an enabled-like property. If null, enabled synchronization is skipped. The setter is expected to accept target as the first argument and a Boolean value as the second. |
Returns: IDisposable -- A disposable that unbinds the command and stops enabled synchronization.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when command is null. |