- 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.
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.
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 - illustrates how to create bindable properties that support change notifications.
- POCO Properties - introduces POCO (Plain Old CLR Objects) classes, supported by the DevExpress MVVM Framework.
- POCO Dependencies - illustrates how to implement dependent properties, which update their values when other related properties are modified.
- Meta-POCO Bindings - explains how to move declarations of OnPropertyChanged callbacks into separate metadata classes.
- Collection Bindings - describes how to populate collections from the required source.
- UI Triggers - explains how to use triggers to tie separate UI elements that should update their visual states in accordance.
- Legacy and Nested ViewModels - demonstrates how to work with child and legacy ViewModels.
- Value Converters - this group illustrates how to convert bindable property values.
Explains how to move 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 - illustrates how to use 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 - illustrates how to implement commands for delayed or continuous tasks that can be cancelled.
- Legacy Commands - this group shows how to use 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 - illustrates how to use services, implemented by DevExpress. You can find the list of DevExpress services in this article.
- Custom Services - explains how to create, register and use 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 - illustrates how to replace a cancellable event (e.g., the FormClosing event) with a behavior.
- Event-to-Command Behavior - explains how to relate any event raised for a UI element with a desired behavior.
- Custom Behaviors - illustrates how to implement and use custom behaviors.
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 document describes how to implement this communication using the DevExpress Messenger.
The application, built entirely according to MVVM concepts, will have multiple separate Views and ViewModels, sometimes from different assemblies. When you need to navigate to a separate application module, the MVVM Framework needs to know what particular View it should display. From this topic, you will learn multiple methods of how to pass a required View when the navigation occurs.