C# Class ReactiveUI.ViewModelActivator

ViewModelActivator is a helper class that you instantiate in your ViewModel classes in order to help with Activation. Views will internally call this class when the corresponding View comes on screen. This means you can set up resources such as subscriptions to global objects that should be cleaned up on exit. Once you instantiate this class, use the WhenActivated method to register what to do when activated. View Activation is **not** the same as being loaded / unloaded; Views are Activated when they *enter* the Visual Tree, and are Deactivated when they *leave* the Visual Tree. This is a critical difference when it comes to views that are recycled, such as UITableViews or Virtualizing ScrollViews. Create this class solely in the **Base Class** of any classes that inherit from this class (i.e. if you create a FooViewModel that supports activation, the instance should be protected and a child BarViewModel should use the existing ViewModelActivator). NOTE: You **must** set up Activation in the corresponding View when using ViewModel Activation.
Afficher le fichier Open project: reactiveui/ReactiveUI Class Usage Examples

Méthodes publiques

Méthode Description
Activate ( ) : IDisposable

This method is called by the framework when the corresponding View is activated. Call this method in unit tests to simulate a ViewModel being activated.

Deactivate ( bool ignoreRefCount = false ) : void

This method is called by the framework when the corresponding View is deactivated.

ViewModelActivator ( ) : System

Private Methods

Méthode Description
addActivationBlock ( Func block ) : void

Method Details

Activate() public méthode

This method is called by the framework when the corresponding View is activated. Call this method in unit tests to simulate a ViewModel being activated.
public Activate ( ) : IDisposable
Résultat IDisposable

Deactivate() public méthode

This method is called by the framework when the corresponding View is deactivated.
public Deactivate ( bool ignoreRefCount = false ) : void
ignoreRefCount bool Force the VM to be deactivated, even /// if more than one person called Activate.
Résultat void

ViewModelActivator() public méthode

public ViewModelActivator ( ) : System
Résultat System