Skip to content

Applies to

net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-tvos18.0, net9.0-maccatalyst18.0, net9.0-ios18.0, net9.0-macos15.0, net9.0-desktop1.0, net8.0, net8.0-macos14.5, net8.0-ios18.0, net8.0-maccatalyst18.0, net8.0-macos15.0, net8.0-tvos18.0, net8.0-ios17.5, net8.0-maccatalyst17.5, netstandard2.1, net481, net462, net471

Attributes: [RequiresUnreferencedCode("Runtime interaction fallback resolves the property chain by reflection.")]

public static IDisposable BindInteraction<TViewModel, TInput, TOutput>(TViewModel? viewModel, Expression<Func<TViewModel, IInteraction<TInput, TOutput>>> interactionProperty, Func<IInteraction<TInput, TOutput>, IDisposable> register, string bindingExpression) where TViewModel : class

View source

Summary: Keeps a handler registered against whichever interaction the observed property holds.

Type parameters

NameDescription
TViewModelThe type declaring the interaction property.
TInputThe type the interaction takes.
TOutputThe type the interaction produces.

Parameters

NameTypeDescription
viewModelTViewModel?The object declaring the interaction property.
interactionPropertyExpression>>The property holding the interaction to handle.
registerFunc, IDisposable>Registers the caller's handler against one interaction.
bindingExpressionstringThe bound expression, named when the observation faults.

Returns: IDisposable -- A disposable that, when disposed, unregisters the handler and stops observing.

Remarks

        The registration follows the property: replacing the interaction unregisters the handler from the one it
        held before, so a view model that swaps an interaction does not leave a handler on the old one. A null view
        model holds no property to observe, so nothing is registered rather than the call faulting.
        

Exceptions

TypeCondition
System.ArgumentNullExceptioninteractionProperty or register is null.