Introduction

Sundstrom MVVM consists of the following basic concepts:

  • ObservableObject implements INotifyPropertyChanged and provides basic functionality for property change notification.
  • ViewModelBase extends ObservableObject and should be used as a base class for view models. It has properties for checking whether one is currently running in a designer.
  • ExtendedViewModelBase extends ViewModelBase and adds validation functionality. This can be implemented either through the use of validation attributes or custom methods with a certain convention.
  • More stuff... explore the library!

ExtendedViewModelBase

The main purpose of ExtendedViewModelBase is to provide additional functionality such as validation.

Validation

One can take advantage of validation in two ways - that can be combined if so is desired.

Validation is triggered manually. Methods Validate or ValidateProperty on the view model.

Using validation attributes

Decorate properties with either provided or custom attributes deriving from Sundstrom.MVVM.Validation.ValidationAttribute.

Implementing validation method

Implement a method that provides validation logic.

It can either be identified through the use of an attribute or by naming convention (Validate<PropertyName>).

The method must either return a value (or null) of type ValidationResult or System.Boolean. It can return void but then the error must be registered manually in the validation method using AddError.

There are also some useful attributes that help the framework identify validation methods:

  • ValidationMethodAttribute - Signifies that the method is a validation method Property name as parameter.
  • NotValidationMethodAttribute - Overrides naming convention

Last edited May 22, 2014 at 8:27 PM by RobertSundstrom, version 10