Project Description
an Implementation of the MVC UI design in WPF - let's call it Wrails....

Implemented by Yonatan Betzer - Bacchus Software Design

This project tries to implement in WPF a framework similar to the one originally developed by the good people of Adobe, for the Flex environments - the Adobe framework was named "Cairngorm".

WPF MVC is a combination of several design patterns, used here to create a great UI implementation framework - both flexible and robust.

you can search the web for extensive documentation of the Cairngorm microarchitecture - to learn more about its benefits and architecture. the general principle is explained below :

The UI is devided into 3 parts : Model, View, Control

Model - represented by all state variables, grouped in a single, singleton, class. (ModelLocator.cs)
View - The visible parts of the UI - "Drawings" only - no logic is implemented here ! all the UI controls do is raise special "Cairngorm events" - that are captured and handled by the Control mechanisms.
UI object's properties are bound to the Model's state variables.
Control - the Control consists of four parts :
Events - several classes of events are created, each class representing a group of related events. each
event has a unique Name.
Controller -events are registered on the (singleton) controller class : a link is made between an event and the
Command class that handles it.
Command - each Command class corresponds to an "Event" class - and handles all its events.
the command classes contain the UI logic - they can change Model variables, call delegates
and handle delegate call results. they can also Dispatch new events for the Controller to catch.
Delegate - Classes that are used to communicate with lower layers of the Application - calling a web service,
using the DAL, BL.... Delegates call methods on the class that called them using the IResponder

How do I add a feature on this kind of UI ?

a. add a delegate that calles the required logic from "outside" the UI.
b. add an Event class, or a new string name to an existing kind. inherit CairngormEvent
c. add a command class, implement ICommand and IResponder
d. Connect the event and the command - use addCommand(...) on Controller.cs
e. create the UI required for your new feature - bind it to state variables on the model. don't forget to set DataContext = ModelLocator.Singleton !
f. have the UI raise your new event, using the static CairngormEventDispatcher.dispatchEvent() command.
g. That's All !

I know it seems a bit lengthy at first - but you are gonna thank yourself for using this framework when your app grows !

As usual - you don't really know what it is until you try for yourself...

Last edited Sep 7, 2008 at 10:04 AM by ybetzer, version 5