DevExpress MVVM Framework
- 4 minutes to read
This section will guide you through the main aspects of WinForms MVVM and its implementation using the DevExpress MVVM Framework. All topics have the associated examples within the Mvvm Best Practices demo. The related notification is displayed before each new section (see the figure below).
This demo features a live preview, which means you can modify an example code to immediately see the result. Additionally, each example can be opened in your Visual Studio as a separate solution.
Help Articles
-
The MVVM Framework processes your application code and interprets specific code snippets in its own way. For instance, a property can be perceived as bindable if its syntax is right. These syntax rules are called conventions. Conventions allow you to avoid writing extra code, since you know that the Framework will “understand” what you expect from it and automatically generate everything needed. This document gathers all MVVM Framework conventions that you need to be aware of when building an MVVM application.
-
This document illustrates how to build fluent API expressions using extension methods provided by the DevExpress MVVM Framework.
Data Bindings and Notifications
This document is dedicated to data bindings and notifications, used to inform the application about bound objects changing their values. Contains the following groups.
- Concepts - describes the traditional ‘WinForms way’ of data bindings.
- Base Classes - creates bindable properties that support change notifications.
- POCO Properties - introduces POCO (Plain Old CLR Objects) classes, supported by the DevExpress MVVM Framework.
- POCO Dependencies - implements dependent properties, which update their values when other related properties are modified.
- Meta-POCO Bindings - moves declarations of OnPropertyChanged callbacks into separate metadata classes.
- Collection Bindings - populates collections from the required source.
- UI Triggers - uses triggers to tie separate UI elements that should update their visual states in accordance.
- Legacy and Nested ViewModels - works with child and legacy ViewModels.
- Value Converters - converts bindable property values.
-
Moves UI element functionality from event handlers to commands - objects that encapsulate specific actions, executed when the related command is used. This document contains the following chapters.+
- Delegate Commands - uses simple commands, designed for synchronously executed actions.
- POCO Commands - explains how methods from your POCO classes turn into commands that can be bound to target UI elements and support the CanExecute behavior.
- Asynchronous Commands - implements commands for delayed or continuous tasks that can be cancelled.
- Legacy Commands - uses commands, defined in your custom non-POCO classes.
-
This document is dedicated to Services - interfaces used to provide a specific UI-aware functionality for Views 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. The document contains two sections.
- DevExpress Services - uses services, implemented by DevExpress. You can find the list of DevExpress services in Standard DevExpress Services.
- Custom Services - creates, registers, and uses your own custom services.
-
Behaviors are used to add a certain functionality to an object without modifying it from the inside. For instance, most often clicking the close button of a tab or a form displays a confirmation dialog. This is not the primary close button’s functionality and should be treated as something extra. In MVVM applications, you can do that using behaviors.
- Confirmation Behavior - replaces a cancellable event (for example, the FormClosing event) with a behavior.
- Event-to-Command Behavior - relates any event raised for a UI element with a desired behavior.
- Custom Behaviors - implements and uses custom behaviors.
Layer Communication. Messenger
Since the MVVM pattern is based on separating application layers, you will most certainly need a way for separate Views and ViewModels to communicate with each other. This help topic uses the DevExpress Messenger to implement communication between Views and VideModels.
-
The application, built entirely according to MVVM concepts, will have multiple separate Views and ViewModels, sometimes from different assemblies. To navigate to a separate application module, the MVVM Framework should know what particular View it should display. From this help topic, you will learn how to pass a required View when the navigation occurs.