Table of Contents

Class ViewModelBase

Namespace
EasySoftware.MvvmMini
Assembly
EasySoftware.MvvmMini.dll

Base class for view models. Binds itself to its view and exposes the view's load and unload events as the overridable Loaded() and Unloaded() methods.

public abstract class ViewModelBase : ModelBase, IViewModel, IModel, INotifyPropertyChanged, INotifyDataErrorInfo, IErrorContainer
Inheritance
ViewModelBase
Implements
Derived
Inherited Members

Constructors

ViewModelBase(IViewAdapter)

Initializes a new instance and sets it as the data context of the view.

protected ViewModelBase(IViewAdapter viewAdapter)

Parameters

viewAdapter IViewAdapter

The adapter of the view that belongs to this view model.

Fields

_viewAdapter

The adapter of the view that belongs to this view model.

protected IViewAdapter _viewAdapter

Field Value

IViewAdapter

Properties

IsBusy

Gets or sets a value indicating whether the view model is busy with long-running work.

public bool IsBusy { get; set; }

Property Value

bool

Title

Gets or sets the title of the view model, for example a window caption or a tab header.

public string Title { get; set; }

Property Value

string

UniqueId

Gets an identifier that distinguishes this view model instance from others.

public string UniqueId { get; protected set; }

Property Value

string

View

Gets the view of this view model, for use in data templates and content controls.

public object View { get; }

Property Value

object

Methods

Loaded()

Called the first time the view is loaded. Override it to load data. Does nothing by default.

protected virtual Task Loaded()

Returns

Task

A task that completes when loading is done.

Unloaded()

Called when the view is unloaded. Does nothing by default.

protected virtual Task Unloaded()

Returns

Task

A task that completes when the work is done.