Skip to main content

MVVM Framework

  • 3 minutes to read

The DevExpress MVVM Framework helps you to use the Model-View-ViewModel design pattern in WinUI applications. Refer to the following MSDN article for more information about this pattern: The MVVM Pattern.

This documentation section contains the following topics that describe features of the DevExpress MVVM Framework.

View Models

The following classes simplify bindable property implementation:

BindableBase
A ViewModel that supports the INotifyPropertyChanged interface and allows you to use GetProperty and SetProperty methods to implement bindable properties.
ViewModelBase
The BindableBase descendant that implements the ISupportUIServices interface and allows you to access UI Services registered within a View.
View Models Generated at Compile Time

The MVVM Framework allows you to produce boilerplate code for your View Models. In this case, you do not need to implement each command or property.

Run Demo: ViewModel Generator Module in the WinUI MVVM Demo

Commands

Commands allow you to define actions in a View Model and then bind to them from any place in a View. DevExpress WinUI MVVM Framework includes the following commands:

DelegateCommand
A delegate command that implements the ICommand interface and calls your parameterless delegates when Execute and CanExecute logic is invoked on the command.
DelegateCommand<T>
A delegate command that implements the ICommand interface and calls your parameterized delegates when Execute and CanExecute logic is invoked on the command.
AsyncCommand
An asynchronous command without a command parameter.
AsyncCommand<T>
An asynchronous command whose Execute(T) and CanExecute(T) delegates accept a command parameter of the T type.

Behaviors

Behaviors extend the capabilities of visual controls and adhere to the MVVM pattern. You can implement missing functionality with a custom Behavior and use it at any place in your application. DevExpress WinUI MVVM Framework includes the following behaviors:

DependencyPropertyBehavior
Allows you to bind a ViewModel property to a control’s non-dependency property.
EventToCommand
Executes a command in response to a raised event.
FocusBehavior
Focuses a UI control without code-behind.
KeyToCommand
Allows you to specify a key combination that invokes a command.

UI Services

UI services allow you to access UI functionality from your view model in MVVM applications. Although services are defined within Views, their functionality can still be invoked from View Models that may not even include information about Views. DevExpress WinUI MVVM Framework includes the following UI services:

DispatcherService
A UI service that allows you to use the DispatcherQueue to perform actions in a ViewModel.
MessageBoxService
The UI service that allows you to show messages.

Miscellaneous

Messenger
Implements the IMessenger interface and allows you to exchange messages between application modules.
SetPropertyHelper
Contains helper methods that allow you to specify a property value.
TypedDataTemplateSelector
Allows you to define a simple template selection logic in XAML. The class is a declarative way to implement the DataTemplateSelector.
See Also