Skip to content

}},System.Func{ReactiveUI.IInteractionContext{--2,--3},System.Threading.Tasks.Task})} }},System.Func{ReactiveUI.IInteractionContext{--2,--3},System.IObservable{--4}})}

InteractionBindingMixins.BindInteraction(TView, TViewModel?, Expression>>, Func, Task>) method

Defined in

Type: InteractionBindingMixins 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 static IDisposable BindInteraction<TViewModel, TView, TInput, TOutput>(this TView view, TViewModel? viewModel, Expression<Func<TViewModel, IInteraction<TInput, TOutput>>> propertyName, Func<IInteractionContext<TInput, TOutput>, Task> handler) where TViewModel : class where TView : class, IViewFor
  • 2. public static IDisposable BindInteraction<TViewModel, TView, TInput, TOutput, TDontCare>(this TView view, TViewModel? viewModel, Expression<Func<TViewModel, IInteraction<TInput, TOutput>>> propertyName, Func<IInteractionContext<TInput, TOutput>, IObservable<TDontCare>> handler) where TViewModel : class where TView : class, IViewFor

1. Overload

Attributes: [RequiresUnreferencedCode("Dynamic observation uses reflection over members that may be trimmed.")]

public static IDisposable BindInteraction<TViewModel, TView, TInput, TOutput>(this TView view, TViewModel? viewModel, Expression<Func<TViewModel, IInteraction<TInput, TOutput>>> propertyName, Func<IInteractionContext<TInput, TOutput>, Task> handler) where TViewModel : class where TView : class, IViewFor

View source

Summary: Binds an interaction from a view model to a view, allowing the view to handle interaction requests using the specified handler.

Type parameters

NameDescription
TViewModelThe type of the view model that contains the interaction property.
TViewThe type of the view implementing the IViewFor interface.
TInputThe type of the input parameter for the interaction.
TOutputThe type of the output parameter for the interaction.

Parameters

NameTypeDescription
viewTViewThe view instance that will handle the interaction.
viewModelTViewModel?The view model instance containing the interaction property. Can be null if the view is not currently bound to a view model.
propertyNameExpression>>An expression identifying the interaction property on the view model to bind.
handlerFunc, Task>A function that will be invoked to handle each interaction request. Receives the interaction context and returns a task representing the asynchronous operation.

Returns: IDisposable -- An IDisposable that can be disposed to unbind the interaction and release associated resources.

Remarks

This method enables the view to respond to interaction requests initiated by the view model, such as displaying dialogs or requesting user input. The returned IDisposable should be disposed when the binding is no longer needed, such as when the view is unloaded, to avoid memory leaks. This method uses reflection and may not be compatible with trimming or AOT scenarios.

2. Overload

Attributes: [RequiresUnreferencedCode("Dynamic observation uses reflection over members that may be trimmed.")]

public static IDisposable BindInteraction<TViewModel, TView, TInput, TOutput, TDontCare>(this TView view, TViewModel? viewModel, Expression<Func<TViewModel, IInteraction<TInput, TOutput>>> propertyName, Func<IInteractionContext<TInput, TOutput>, IObservable<TDontCare>> handler) where TViewModel : class where TView : class, IViewFor

View source

Summary: Binds an interaction from a view model to a view, allowing the view to handle interaction requests using the specified handler.

Type parameters

NameDescription
TViewModelThe type of the view model containing the interaction property.
TViewThe type of the view implementing the IViewFor interface.
TInputThe type of the input parameter for the interaction.
TOutputThe type of the output parameter for the interaction.
TDontCareThe type of the value produced by the handler observable. This value is ignored.

Parameters

NameTypeDescription
viewTViewThe view instance that will handle the interaction.
viewModelTViewModel?The view model instance containing the interaction property. Can be null if the view is not currently bound to a view model.
propertyNameExpression>>An expression identifying the interaction property on the view model to bind.
handlerFunc, IObservable>A function that handles the interaction by processing the interaction context and returning an observable sequence. The result of the observable is ignored.

Returns: IDisposable -- An IDisposable that can be disposed to unbind the interaction and release associated resources.

Remarks

This method enables the view to respond to interaction requests initiated by the view model, typically for user-driven workflows such as dialogs or prompts. The handler is invoked each time the interaction is triggered. The returned IDisposable should be disposed when the binding is no longer needed, such as when the view is unloaded.