Skip to content

})} },ReactiveUI.IViewFor)} })} },ReactiveUI.IViewFor)} ,ReactiveUI.IViewFor)}

WpfViewForMixins.WhenActivated(TView, Func>) method

Defined in

Type: WpfViewForMixins Namespace: ReactiveUI Assembly: ReactiveUI.Wpf.dll

Applies to

net10.0-windows10.0.19041, net9.0-windows10.0.19041, net8.0-windows10.0.19041, net462, net481

Overloads

  • 1. public static IDisposable WhenActivated<TView>(this TView item, Func<IEnumerable<IDisposable>> block) where TView : FrameworkElement, IActivatableView
  • 2. public static IDisposable WhenActivated<TView>(this TView item, Func<IEnumerable<IDisposable>> block, IViewFor? view) where TView : FrameworkElement, IActivatableView
  • 3. public static IDisposable WhenActivated<TView>(this TView item, Action<Action<IDisposable>> block) where TView : FrameworkElement, IActivatableView
  • 4. public static IDisposable WhenActivated<TView>(this TView item, Action<Action<IDisposable>> block, IViewFor view) where TView : FrameworkElement, IActivatableView
  • 5. public static IDisposable WhenActivated<TView>(this TView item, Action<CompositeDisposable> block, IViewFor? view = null) where TView : FrameworkElement, IActivatableView

1. Overload

Attributes: [RequiresUnreferencedCode("Evaluates expression-based member chains via reflection; members may be trimmed.")]

public static IDisposable WhenActivated<TView>(this TView item, Func<IEnumerable<IDisposable>> block) where TView : FrameworkElement, IActivatableView

View source

Summary: Activates the specified WPF view and registers a block of disposables to be disposed when the view is deactivated.

Type parameters

NameDescription
TViewThe view type.

Parameters

NameTypeDescription
itemTViewThe view to activate.
blockFunc>A function that returns disposables to be disposed when the view is deactivated.

Returns: IDisposable -- An IDisposable that deactivates the view and disposes the registered disposables when disposed.

2. Overload

Attributes: [RequiresUnreferencedCode("Evaluates expression-based member chains via reflection; members may be trimmed.")]

public static IDisposable WhenActivated<TView>(this TView item, Func<IEnumerable<IDisposable>> block, IViewFor? view) where TView : FrameworkElement, IActivatableView

View source

Summary: Registers a block of disposables to be activated and disposed in sync with the WPF view lifecycle.

Type parameters

NameDescription
TViewThe view type.

Parameters

NameTypeDescription
itemTViewThe view to activate.
blockFunc>A function that returns disposables to be disposed when the view is deactivated.
view[IViewFor?](#An optional view instance to use for view model activation.

Returns: IDisposable -- An IDisposable that deactivates the view and disposes the registered disposables when disposed.

3. Overload

Attributes: [RequiresUnreferencedCode("Evaluates expression-based member chains via reflection; members may be trimmed.")]

public static IDisposable WhenActivated<TView>(this TView item, Action<Action<IDisposable>> block) where TView : FrameworkElement, IActivatableView

View source

Summary: Registers a block of code to be executed when the specified WPF view is activated.

Type parameters

NameDescription
TViewThe view type.

Parameters

NameTypeDescription
itemTViewThe view to activate.
blockAction>An action that receives a callback for registering disposables.

Returns: IDisposable -- An IDisposable that unregisters the activation logic.

4. Overload

Attributes: [RequiresUnreferencedCode("Evaluates expression-based member chains via reflection; members may be trimmed.")]

public static IDisposable WhenActivated<TView>(this TView item, Action<Action<IDisposable>> block, IViewFor view) where TView : FrameworkElement, IActivatableView

View source

Summary: Registers a block of code to be executed when the specified WPF view is activated.

Type parameters

NameDescription
TViewThe view type.

Parameters

NameTypeDescription
itemTViewThe view to activate.
blockAction>An action that receives a callback for registering disposables.
view[IViewFor](#The view instance to use for view model activation.

Returns: IDisposable -- An IDisposable that unregisters the activation logic.

5. Overload

Attributes: [RequiresUnreferencedCode("Evaluates expression-based member chains via reflection; members may be trimmed.")]

public static IDisposable WhenActivated<TView>(this TView item, Action<CompositeDisposable> block, IViewFor? view = null) where TView : FrameworkElement, IActivatableView

View source

Summary: Activates the specified WPF view and manages the provided disposables for the duration of the activation lifecycle.

Type parameters

NameDescription
TViewThe view type.

Parameters

NameTypeDescription
itemTViewThe view to activate.
blockActionAn action that receives a composite disposable for activation-related resources.
view = null[IViewFor?](#An optional view instance to use for view model activation.

Returns: IDisposable -- An IDisposable that unregisters the activation logic.