Table of Contents

MVVM

XToolkit.WhiteLabel is a framework based on the Model-View-ViewModel (MVVM) pattern. WhiteLabel helps you to separate your View from your Model which creates applications that are cleaner and easier to maintain and extend. It also creates testable applications and allows you to have a much thinner user interface layer (which is more difficult to test automatically).

XToolkit.WhiteLabel is intended to be a fully-featured MVVM Framework and does include some features like ViewModel-first navigation, DI, and messaging.

XToolkit.Common can serve as a basis for developers who want to create their own MVVM implementation. By providing only the most basic of extra functionality but still following common conventions it should be the easiest option.

Core files

ObservableObject

ObservableObject contains an implementation of the INotifyPropertyChanged interface and is used as a base class for all ViewModels. This makes it easy to update bound properties on the View.

ViewModelBase

ViewModelBase is the base class for all page view-models in the application.

Commands

RelayCommand/AsyncCommand contains an implementation of the ICommand interface and allows the View to call commands on the ViewModel, rather than handle UI events directly.

XToolkit.WhiteLabel assumes View-based navigation. This means that a ViewModel will trigger navigation to another View.

You can learn more about Navigation here.

Snippets

Basic property

private bool _isBusy;

public bool IsBusy
{
    get => _isBusy;
    private set => Set(ref _isBusy, value);
}

Constructor

Init the command via constructor:

// ctor
{
    StartCommand = new AsyncCommand(StartAsync);
}

public IAsyncCommand StartCommand { get; }

Lazy

Lazy initialization of the command:

private AsyncCommand _startCommand;

public IAsyncCommand StartCommand => _startCommand ??= new AsyncCommand(StartAsync);