$npx -y skills add DevExpress/agent-skills --skill devexpress-wpf-mvvmBuild WPF applications with the DevExpress MVVM Framework — view-model strategies (compile-time GenerateViewModel source generator, runtime POCO ViewModelSource, ViewModelBase, BindableBase), DelegateCommand/AsyncCommand, predefined services (IMessageBoxService, IDialogService, I
| 1 | # DevExpress WPF MVVM Framework |
| 2 | |
| 3 | `DevExpress.Mvvm` is a full-featured MVVM framework for WPF — view-model base classes, code generators (compile-time and runtime), commands (sync and async), 25+ predefined services for typical UI tasks (message boxes, dialogs, document management, dispatcher, navigation, splash screens), behaviors that replace code-behind, and three view-model-communication mechanisms (parameter passing, parent-child relationships, messenger). |
| 4 | |
| 5 | This skill covers picking the right view-model strategy, defining bindable properties and commands, calling services from view models, attaching behaviors, and routing data between view models. |
| 6 | |
| 7 | ## When to Use This Skill |
| 8 | |
| 9 | Use this skill when you need to: |
| 10 | |
| 11 | - Pick a view-model strategy for a new or existing project |
| 12 | - Generate boilerplate code (properties, INotifyPropertyChanged, commands) at compile time |
| 13 | - Wire commands (sync `DelegateCommand` or async `AsyncCommand`) to methods |
| 14 | - Show message boxes / dialogs / file pickers / notifications from a view model |
| 15 | - Replace code-behind event handlers with behaviors (`EventToCommand`, `KeyToCommand`, ...) |
| 16 | - Pass initial data to a child view model (`ISupportParameter`) |
| 17 | - Access services registered on the parent view's view model from a child (`ISupportParentViewModel`) |
| 18 | - Broadcast notifications across loosely coupled view models (`Messenger`) |
| 19 | |
| 20 | ## Prerequisites & Installation |
| 21 | |
| 22 | ### NuGet Packages |
| 23 | |
| 24 | | Package | Provides | |
| 25 | |---------|---------| |
| 26 | | `DevExpress.Wpf.Core` | `ViewModelBase`, `BindableBase`, `Messenger`, all predefined services (`IMessageBoxService`, `IDialogService`, etc.), behaviors, `dxmvvm:` namespace | |
| 27 | | `DevExpress.Mvvm` | Standalone MVVM library (the same types) — use when not bringing the rest of DX WPF | |
| 28 | | `DevExpress.Mvvm.CodeGenerators` | Compile-time source generator for `[GenerateViewModel]` | |
| 29 | |
| 30 | For a typical DevExpress WPF app, **install `DevExpress.Wpf.Core` only** — it brings everything. For a pure-MVVM library that doesn't reference UI controls, install `DevExpress.Mvvm` standalone. |
| 31 | |
| 32 | For compile-time view-model generation, **also install** `DevExpress.Mvvm.CodeGenerators`: |
| 33 | |
| 34 | ```bash |
| 35 | dotnet add package DevExpress.Wpf.Core |
| 36 | dotnet add package DevExpress.Mvvm.CodeGenerators # for compile-time view models |
| 37 | ``` |
| 38 | |
| 39 | ### Requirements per Strategy |
| 40 | |
| 41 | | | POCO View Models (runtime) | View Models generated at compile time | |
| 42 | |---|---|---| |
| 43 | | C# version | 6+ | 9+ | |
| 44 | | .NET Framework | 4.5.2+ | 4.6.1+ | |
| 45 | | .NET Core | 3.0+ | 3.0+ | |
| 46 | | VB support | Yes | No | |
| 47 | | Debug-step into generated code | No | Yes | |
| 48 | |
| 49 | **For new projects, prefer the compile-time generator** — better tooling, debuggable, no runtime reflection cost. Use POCO only when targeting older runtimes or VB.NET. Use `ViewModelBase` when integrating with code that already uses it. |
| 50 | |
| 51 | A valid DevExpress license is required. All DevExpress packages in a project must share the same version. |
| 52 | |
| 53 | ## XAML Namespaces |
| 54 | |
| 55 | ```xml |
| 56 | xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" |
| 57 | xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" |
| 58 | ``` |
| 59 | |
| 60 | | Prefix | Use for | |
| 61 | |---|---| |
| 62 | | `dxmvvm:` | `Interaction.Behaviors`, `EventToCommand`, `KeyToCommand`, `ViewModelSource`, `ViewModelExtensions`, `MessageBoxService` (and most services) | |
| 63 | | `dx:` | Some services live here too (e.g., `DXMessageBoxService`) — match what's in the docs | |
| 64 | |
| 65 | ## View-Model Strategies — Picker |
| 66 | |
| 67 | | Strategy | When to use | |
| 68 | |---|---| |
| 69 | | **`[GenerateViewModel]`** (compile-time, recommended) | New projects on C# 9+ / .NET 5+. Best tooling. | |
| 70 | | **`ViewModelSource.Create<T>()`** (POCO, runtime-generated) | When you need VB support, or compile-time generator is unavailable | |
| 71 | | **`ViewModelBase`** (dir |