Skip to end of metadata
Go to start of metadata

Provides common functionality for ViewModel classes.

Definition

Summary

The following table summarizes the members exposed in this class.

Public Constructors

ViewModelBase Constructor() Initializes a new instance of the ViewModelBase class.
ViewModelBase Constructor(IViewModel) Initializes a new instance of the ViewModelBase class with the owner ViewModel.

Public Properties

ActionPresenter Gets the action presenter.
ActionToastPresenter Gets the action toast presenter.
ActivityPresenter Gets the activity presenter.
Context Gets the application context.
DialogPresenter Gets the dialog presenter.
LocalizationService Gets the localization service.
Logger Gets the logger for this instance.
MessagePresenter Gets the message presenter.
MobileService Gets the mobile service implemented in this instance.
NavigationService Gets the navigation service.
PresenterService Gets the presenter service.
Resources Gets the resources that contains the localizable items for this instance.
Title Gets or sets the title of the ViewModel which can be bound to the View.
ToastPresenter Gets the toast presenter.

Public Methods

Dispose() Releases all resource used by the ViewModelBase object.
GetService<TService>() Gets the registered service based on the specified type parameter.
GetService<TService>(bool) Gets the service and optionally return a new instance of the service.
InvokeViewMethod(string, Object[]) Call the specified method on the view context associated to this ViewModel.
Navigated(NavigatedParameter) Called when this instance is navigated.
ShouldNavigate(NavigationTarget) Called when the navigation service is about to perform navigation.

Protected Methods

Dispose(bool) Dispose this instance.
Finalize() Releases unmanaged resources and performs other cleanup operations before the ViewModelBase is reclaimed by garbage collection.
OnPropertyChanged(string) Raises the property changed event.
UpdateResources() Called when the resources need to be updated, commonly due to UI culture change called by ILocalizationService.

Events

PropertyChanged Occurs when property changed.

Public Constructors

public ViewModelBase()

Initializes a new instance of the ViewModelBase class.

public ViewModelBase(IViewModel owner)

Initializes a new instance of the ViewModelBase class with the owner ViewModel.

Parameters

owner The owner view model which represents the actual view context.

Public Properties

public IActionPresenter ActionPresenter { get; }

Gets the action presenter.

public IActionToastPresenter ActionToastPresenter { get; }

Gets the action toast presenter.

public IActivityPresenter ActivityPresenter { get; }

Gets the activity presenter.

public IApplicationContext Context { get; }

Gets the application context.

public IDialogPresenter DialogPresenter { get; }

Gets the dialog presenter.

public ILocalizationService LocalizationService { get; }

Gets the localization service.

public ILog Logger { get; }

Gets the logger for this instance.

public IMessagePresenter MessagePresenter { get; }

Gets the message presenter.

public IMobileService MobileService { get; }

Gets the mobile service implemented in this instance.

public INavigationService NavigationService { get; }

Gets the navigation service.

public IPresenterService PresenterService { get; }

Gets the presenter service.

public IObservableResource Resources { get; }

Gets the resources that contains the localizable items for this instance.

public string Title { get; set; }

Gets or sets the title of the ViewModel which can be bound to the View.

public IToastPresenter ToastPresenter { get; }

Gets the toast presenter.

Public Methods

public void Dispose()

Releases all resource used by the ViewModelBase object.

Remarks

Call ViewModelBase when you are finished using the ViewModelBase. The ViewModelBase method leaves the ViewModelBase in an unusable state. After calling ViewModelBase, you must release all references to the ViewModelBase so the garbage collector can reclaim the memory that the ViewModelBase was occupying.

public TService GetService<TService>()

Gets the registered service based on the specified type parameter.

Type Parameters

TService The service type to retrieve.

Return Types

The service.

public TService GetService<TService>(bool newInstance)

Gets the service and optionally return a new instance of the service.

Type Parameters

TService The 1st type parameter.

Parameters

newInstance If set to true new instance.

Return Types

The service.

public void InvokeViewMethod(string methodName, Object[] args)

Call the specified method on the view context associated to this ViewModel.

Parameters

methodName Method name.
args Arguments.

public void Navigated(NavigatedParameter parameter)

Called when this instance is navigated.

Parameters

parameter Parameter.

public bool ShouldNavigate(NavigationTarget target)

Called when the navigation service is about to perform navigation.

Parameters

target Target.

Return Types

true

Protected Methods

protected void Dispose(bool isDisposing)

Dispose this instance.

Parameters

isDisposing If set to true is disposing.

protected void Finalize()

Releases unmanaged resources and performs other cleanup operations before the ViewModelBase is reclaimed by garbage collection.

protected void OnPropertyChanged(string propertyName)

Raises the property changed event.

Parameters

propertyName Property name.

protected void UpdateResources()

Called when the resources need to be updated, commonly due to UI culture change called by ILocalizationService.

Events

public event PropertyChangedEventHandler PropertyChanged

Occurs when property changed.

  • No labels