Design-Time Features > Using C1DataSource in MVVM with other MVVM framework |
C1DataSource can be used to build Model-View-View-Model (MVVM) applications with any other MVVM frameworks.
C1DataSource offers several features to make your MVVM development easier:
Given that C1DataSource can be used to simplify MVVM programming, as seen in the Simplifying MVVM topic, it’s clearly a tool that can be used for MVVM.
There are a plethora of tools and frameworks that developers can use to aid them in their work with MVVM, but very few that can help them create view model classes. The majority are designed to help with tasks such as passing commands and messages between the view and view model. Creating view model classes and then synchronizing them with model data is left almost entirely to manual coding. This is the primary cause of code bloating in most MVVM applications and precisely the one that C1DataSource is designed to alleviate in a way that is entirely compatible with other frameworks.
You can use any framework you like to assist your MVVM application development and simply call on C1DataSource to provide live views to help you create view model classes.
To demonstrate these important points, we provide a sample based on the code from the well-known article by Josh Smith, one of the authors of MVVM, "WPF Apps With The Model-View-ViewModel Design Pattern" (http://msdn.microsoft.com/en-us/magazine/dd419663.aspx).
Please refer to the pre-installed product samples through the following path:
Documents\ComponentOne Samples\WinForms
Essentially all the files in our modified sample are the same as the originals (bar a few cosmetic changes) except one (ViewModels\OrdersViewModel.cs).
In this file, we build the view model class the C1DataSource way, using live views. You can see how many re-shaping functions are applied to model data to construct a view model, all done exclusively through LINQ. This made it easy and required little code. The best part is that it synchronizes automatically with model data when data in either of the two layers is changed - no synchronization code was necessary.
The fact that we only changed the way that the view model classes themselves were created (they are still derived from the original base class 'ViewModelBase') and made no other changes to the framework code that Josh Smith had employed in his original sample should serve as an example that C1DataSource is entirely compatible with other frameworks. You can continue to use your preferred frameworks when working with MVVM, but now you have an additional tool to make your MVVM development even easier.