Skip to content

,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, string, PropertyInfo) method

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)

View source

Summary: Creates a commands binding from event and a property.

Parameters

NameTypeDescription
commandICommand?Command.
targetobject?Target.
commandParameterIObservableCommand parameter.
eventNamestringEvent name.
enabledPropertyPropertyInfoEnabled 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

View source

Summary: Creates a command binding from an event using explicit add/remove handler delegates and optionally synchronizes an enabled property with CanExecute.

Type parameters

NameDescription
TEventArgsThe event arguments type.

Parameters

NameTypeDescription
commandICommand?The command to bind.
targetobject?The event source object.
commandParameterIObservable?Observable producing command parameter values. If null, target is used.
addHandlerAction>Adds the handler to the event source.
removeHandlerAction>Removes the handler from the event source.
enabledSetterAction?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

TypeCondition
System.ArgumentNullExceptionThrown 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)

View source

Summary: Creates a command binding from an event using explicit add/remove handler delegates and optionally synchronizes an enabled property with CanExecute.

Parameters

NameTypeDescription
commandICommand?The command to bind.
targetobject?The event source object.
commandParameterIObservable?Observable producing command parameter values. If null, target is used.
addHandlerActionAdds the handler to the event source.
removeHandlerActionRemoves the handler from the event source.
enabledSetterAction?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

TypeCondition
System.ArgumentNullExceptionThrown when command is null.