MVVM : Cinch
Cinch is a free open source MVVM framework that I put together and will/has been released to the community. It has answers lots of the WPF/MVVM framework issues I have had when doing MVVM.
Here is a list of what Cinch contains:
- Allows view to communicate LifeCycle events to a ViewModel without any hard reference links being maintained, and no IView interface requirements there is no link at all between the View and the ViewModel
- Has several attached behaviours for common tasks such as
- Numeric text entry
- Run an ICommand in a ViewModel based on a RoutedEvent from a XAML FrameworkElement
- Have a group of such ICommand/RoutedEvent Events for a single XAML FrameworkElement
- Allows the ViewModel to determine is a Models data should be editable, the UI simple updates via bindings, based on the ViewModel driven editability state. This is available at individual Model field level, so it’s very flexible
- Delegate validation rules which allows validation rules to be as granular as necessary
- Native IDataErrorInfo support using the Delegate rules approach
- IEditableObject usage to store/restore object state on edit / cancel edit
- Weak event creation, to allow the creation of WeakEvents
- Weak event subscription, which also allows auto unsubscriptions
- Mediator messaging with WeakReference support out of the box
- DI/IOC using Unity DI Container, to allow alternative Test/actual app service implementations
- Service implementations which include (where Cinch has defaults for WPF/UnitTest for most of these, with the exception of the Popup window service which will be covered in a subsequent article and shall still be available within the attached demo code at any rate)
- Event logger service
- MessageBox service (which can be 100% emulated within unit tests, as if the user actually clicked a
MessageBoxbutton), thus enabling the ViewModel code to be traversed down the correct path - Open file service (which can be 100% emulated within unit tests, as if the user actually chose a file to open in the model
OpenFileDialog), thus enabling the ViewModel code to be traversed down the correct path - Save file service (which can be 100% emulated within unit tests, as if the user actually chose a file to save in the model
SaveFileDialog), thus enabling the ViewModel code to be traversed down the correct path - Popup window service, to control the showing/hiding and setup of Popup Window in WPF (which is a nightmare)
- Threading helpers
- Dispatcher extension methods to allow quick marshalling of a
Action<T>to the correct UI Dispatcher - Application.DoEvents
- Application.DoEvents (for a certain Dispatcher Priority)
- BackgroundTaskManager with callback to alert waiting Unit tests of completion, to allow test to complete or timeout
- ObservableCollection, which notifies CollectionChanged on correct Dispatcher thread
- ObservableCollection, which allows a range of items to be added
- Dispatcher extension methods to allow quick marshalling of a
- MenuItem ICommand ViewModel implementation made easy
- Closeable ViewModels (when working in Tabbed UI enviorment, which is what one should really be doing with MVVM)
Here are the links to Cinch that point to all the articles that describe how to get started with Cinch.
http://www.codeproject.com/KB/WPF/Cinch.aspx
http://www.codeproject.com/KB/WPF/CinchII.aspx
http://www.codeproject.com/KB/WPF/CinchIII.aspx
http://www.codeproject.com/KB/WPF/CinchIV.aspx
http://www.codeproject.com/KB/WPF/CinchV.aspx
http://www.codeproject.com/KB/WPF/CinchVI.aspx
Cinch V2 Articles
http://www.codeproject.com/KB/WPF/CinchV2_1.aspx
http://www.codeproject.com/KB/WPF/CinchV2_2.aspx

