In recent months, we've noticed a spike in customer questions regarding our WinForms MVVM Framework. This increase in demand could not come at a better time as we’ve been hard at work updating demos and documentation. First things first though – I want to mention WinForms MVVM Framework-related changes we expect to ship in v20.1.
New Services
MVVM pattern suggests that you keep data management code separated from the UI - inside ViewModels that are independent from Views. This recommendation means that if you need to open a View as a tab, or close a currently open dialog, or do anything else on a View layer - the ViewModel code that executes these actions should be kept independent from a View. In other words, the "open a new tab" command should not refer to a View control instance. Instead, the application should be able to automatically locate an appropriate UI element that fits the action (for instance, a Document Manager component that displays tabs).
DevExpress MVVM Framework allows you to implement this logic with the help of Services. All you need to do is register the appropriate Service, and call its public methods in a ViewModel. The Framework will automatically find an appropriate View control and "translate" Service methods into specific control commands.
With v20.1, we've extended our existing Service collection with three additional Services:
- WindowService - allows you to open Views as separate XtraForms, RibbonForms or Flyouts.
- CurrentWindowService - allows you to manage windows (forms) from the ViewModel layer. The Service provides methods to change the form's window state or close any active window.
- CurrentDialogService - use this Service to manage open dialogs. Allows you to close a dialog with a specific DialogResult.
To learn more about our WinForms MVVM Services, please refer to the following help topic: Services.
New Tutorial Demo Module
We understand that MVVM can be challenging for those unfamiliar with its underlying concepts. To simplify the learning curve, we've added a "Simple ToDo Application" module to our "MVVM Best Practices" demo. This module demonstrates uses a sample app to demonstrate basic MVVM concepts, such as data binding and ViewModel communications. The "Walkthrough" demo breaks the process down into "bite-sized" steps. Each step is supplied with a description and related code, so you can easily track how empty forms turn into Views, data management code becomes ViewModel classes, and separate layers communicate with one another.
You can also download both C# and Visual Basic versions of this sample app from the Simple TODO Application repository on GitHub.
Documentation Enhancements
In addition to the new walkthrough demo module, we've begun to update our other learning resource. Previous versions focused on a thorough description of what's possible. With v20.1, we’ve shifted focus to clarity and brevity. Our Data Bindings help section now outlines the difference between "regular" and "data" bindings, and demonstrates the best way to implement both. Each binding technique is followed by a demo example. We’ve also overhauled our API Samples section to fit this new pattern.
"Data Bindings" is the first completely reworked section. We expect to update other sections as time allows.
As we work to perfect things, we’d love to get feedback from those currently using MVVM or considering it in a future WinForms project. Let us know if the changes outlined above are of value to your business.