What Is Cinch?

Cinch is a MVVM framework that exposes a number of helper classes to allow the developer to quickly get to grips with creating scalable testable MVVM frameworks as quickly as possible.

Testing was of paramount importance, and Cinch has had this issue in mind from the very beginning, as such you should find it very easy to unit test your code when using Cinch.

Cinch has 2 active releases
  1. Cinch V1 : WPF Only
  2. Cinch V2 : Which is WPF and Silverlight (4.0 or above)
Here is a list of features that Cinch provides
  • View lifecycle events in your ViewModel either by attached behaviours (Cinch V1) or via a deciated UI service (Cinch V2)
  • Event To ICommand preversing all relavant data such as Sender/EventArgs etc etc
  • IEditableObject support on Models (Cinch V1) and ViewModels (Cinch V1 and Cinch V2). Which allows the store/restore of ViewModel object state on edit / cancel edit
  • Flexable delegate based validation rules
  • Native IDataErrorInfo support using the Delegate rules approach
  • Weak event creation, to allow the creation of WeakEvents
  • Weak event subscription, which also allows auto unsubscriptions
  • Weak reference based disconnected messaging Via Mediator pattern
  • Customizable IOC/DI container support for UI Services (Cinch V1 Only)
  • Managed Extensibility support for UI Services (Cinch V2 Only)
  • MVVM MenuItem support
  • Closeable ViewModels (when you are using TabControl say)
  • Workspace supporting View 1st (Cinch V2 WPF Only)
  • Design time data support (Cinch V2 Only)
  • Handful of utilities such as
    • Weak reference based INotifyProperty observer
    • INotifyProperty property name Expression tree helper
    • Binding evaluators (Cinch V2)
  • 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
  • UI Services
    • Event Logger (Cinch V1 Only)
    • MessageBox (Cinch V1 and Cinch V2 WPF/SL)
    • Open File (Cinch V1 and Cinch V2 WPF)
    • Save File (Cinch V1 and Cinch V2 WPF)
    • Popup Window (Cinch V1 and Cinch V2 WPF)
    • Child Window (Cinch V2 SL)
  • ViewModel code generator


Cinch is not meant for creating modular UIs, like PRISM, but it does offer a great many other features that are comparable with PRISM such as

PRISM EventAggregator == Cinch Mediator
PRISM UI Service location == Cinch UI Services

And to some extent PRISM Regions == Cinch Workspaces, though I have to say PRISM regions are excellent, however with Cinch V2 you can also use PRISM v4 (which is MEF based) regions/modules with ease. So you can have your cake and eat it too.

Cinch V1

Cinch V1 is a VS2008 solution which only supported WPF, and was aimed at doing MVVM in a ViewModel 1st approach here is a diagram that may help to cement the list above:


And here is a screen shot of it the demo app that went with Cinch V1
Where it used EntityFramework to use with a simple search type UI, and it demonstrates validation/editing of object, cancelling edits, messaging using the Mediator



Cinch originally started as a codeproject atricle, and people asked me to move the code to codeplex, which I did, but all the documentation is available on codeproject and that should be used as main source of information regarding Cinch.

I will maintain a set of links here, which point to codeproject.

Cinch V1 article links are as follows:
  1. A discussion of what would be included in Cinch (much the same as the list above)
  2. A discussion of attached behaviours/attached commands/modes/weak events/mediator usage
  3. A discussion of UI services/threading helpers/Menus the MVVM way/closeable tabs the MVVM way
  4. A discussion of how to develop models/ViewModels using Cinch
  5. A discussion of how to unit test using Cinch
  6. A discussion on the Cinch demo

Cinch V2

Cinch V2 is a VS2010 solution which supports WPF/Silverlight 4, and was aimed at doing MVVM in a View 1st using design time service which would provide design time data to Blend. It uses Managed Extensibility framework to do all this.
Here are some screen shots of the Cinch V2 demo apps:
  • Cinch V2 WPF Demo
This is the architecural image for Cinch V2 WPF
  • Here are some screen shots of the WPF demo app

And here it is in Blend, note that design time data


  • **
Cinch V2 SilverlightDemo
This is the architecural image for Cinch V2 Silverlight
  • Here are some screen shots of the Silverlight demo app






Cinch V2 article links are as follows:
  1. Discussed the use of MEF and the MefedMVVM library within CinchV2
  2. Discussed the WPF/SL and common services within CinchV2
  3. Discussed the new features of Cinch V2 that were not in Cinch V1
  4. A Deep Dive Into What Has Changed/What Has Stayed The Same
  5. Disecting The WPF Demo App
  6. Disecting The SL4 Demo App
Community based articles:
How to convert a Silverlight Navigation Application to use MVVM using Cinch V2. Which basically shows you how to use the Silverlight inbuilt navigation features with CinchV2 for Silverlight

There is also another very nice demo/project that utilises Cinch V2 for WPF available at SQL Server Companion WPF which basically looks like this




Cinch V2 Working With PRISM v4

For those of you that love PRISM, and want to use PRISM things like Regions/Modules, good news CinchV2 works seamlessly with PRISM 4, you can read all about it using this article
I have created 2 demos to showcase this in the article and here are some screen shots of them in all their glory

Demo 1 : Shows how to use a custom region adaptor (but does not use regions), and also uses some CinchV2 goodies



Demo 2 : Shows how to use a regions/modules, and also uses some CinchV2 goodies





Cinch ViewModel Code Generator

Cinch V1 and Cinch V2 development can be greatly sped up by using the code generator that comes with Cinch. It is actually available within the Cinch V1 solution, but works for both Cinch V1 and Cinch V2 ViewModels
There is an article describing how to use the code generator over at codeproject which you can read using the following link And here is what it looks like when it is running







Cinch Code Snippets

There are a number of community contributed code snippets, which I have checked and these are available from the Cinch patch list using this url: Whats inside:
  1. Cinch: EditableValidatingObject overrides
  2. Cinch: INotifyPropertyChanged for reference type
  3. Cinch: INotifyPropertyChanged for value type
  4. Cinch: INotifyPropertyChanged + DataWrapper for reference type
  5. Cinch: INotifyPropertyChanged + DataWrapper for value type
  6. Cinch: INotifyPropertyChanged for collections
  7. Cinch: INotifyPropertyChanged
  8. Cinch: Command
  9. Cinch: Background worker
  10. Cinch: ViewMode




This WikiPage was created with Codeplex WikiEditor

Last edited Sep 6, 2011 at 8:24 AM by sachabarber, version 26