Click here to Skip to main content
6,630,289 members and growing! (21,799 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Windows Presentation Foundation » General     Intermediate License: The Code Project Open License (CPOL)

WPF: If Heineken did MVVM Frameworks Part 6 of n

By Sacha Barber

It would probably be like Cinch a MVVM framework for WPF
C# (C# 3.0, C# 4.0), .NET (.NET 3.0, .NET 3.5), WPF, Architect, Dev, Design
Version:2 (See All)
Posted:12 Aug 2009
Updated:4 Sep 2009
Views:12,310
Bookmarked:27 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
37 votes for this article.
Popularity: 7.37 Rating: 4.70 out of 5

1

2
4 votes, 10.8%
3

4
33 votes, 89.2%
5

Contents

Cinch Article Series Links

  • Cinch primer article
  • A walkthrough of Cinch, and it's internals I
  • A walkthrough of Cinch, and it's internals II
  • How to develop ViewModels using Cinch
  • How to Unit test ViewModels using Cinch, including how to test Background worker threads which may run within Cinch ViewModels
  • A Demo app using Cinch
  • Introduction

    Last time we started looking at the what a Unit testing using Cinch.

    In this article I will be looking at the following:

    PreRequisites

    The demo app makes use of :

    • VS2008 SP1
    • .NET 3.5 SP1
    • SQL server (see the README.txt in the MVVM.DataAccess project to learn what you have to setup for the demo app database)

    Special Thanks

    So I guess the only way to do this is to just start, so lets get going shall we, but before we do that I just need to repeat the special thanks section, with one addition, Paul Stovell who I forgot to include last time

    Before I start I would specifically like to say a massive thanks to the following people, without whom this article and the subsequent series of articles would never have been possible. Basically what I have done with Cinch is studied most of these guys, seen what's hot, what's not, and come up with Cinch. Which I hope adresses some new ground not covered in other frameworks.

    Mark Smith (Julmar Technology), for his excellent MVVM Helper Library, which has helped me enormously. Mark I know I asked your persmission to use some of your code, which you most kindly gave, but I just wanted to say a massive thanks for your cool ideas, some of which I genuinely had not thought of. I take my hat off to you mate.

    Josh Smith / Marlon Grech (as an atomic pair) for their excellent Mediator Implementation. You boys rock, always a pleasure

    Karl Shifflett / Jaime Rodriguez (Microsoft boys) for their excellent MVVM Lob tour, which I attended, well done lads

    Bill Kempf, for just being Bill and being a crazy wizard like programmer, who also has a great MVVM framework called Onyx, which I wrote an article about some time ago. Bill always has the answers, to tough questions, cheers Bill.

    Paul Stovell for his excellent delegate validation idea, which Cinch uses for validation of business objects

    ALL of the WPF Disciples, for being the best online group to belong to IMHO

    Thanks guys/girl, you know who you are

  • The Demo App

    The Demo App

    In some ways this article will be a bit of strange one, as I have already covered everything you need to know about how to construct the demo app or any other MVVM based app (of course using the Cinch framework), so I will not be covering any code in this article as I think that has been pretty much covered by all the previous articles.

    What this article shall concentrate on is what the demo app looks like and how it is made up, of course while doing that I will explain how and why certain Cinch classes/objects are used and why certain design ideas were followed, but if you are expecting a full run through of the code, this article is not the place for that, you should refer to the previous articles for that.

    I am hoping that by now you are armed with enough Cinch know how to dismantle the demo app by yourselves and see what is going on in it, remember you have all the Cinch articles prior to this one to help you out.

    What It Looks Like

    So far I have written 5 other Cinch articles, and believe it or not there has not been one screen shot of the demo app, which is largely down to the fact that I have been explaining the framework and how to test with it, where as this article talks about the look and structure of the demo app, so without further ado we need to see some screen shots. So let's have a look at some screen shots shall we:

    Start Page

    Click to view bigger image

    Add/Edit Customer (Add new mode shown below)

    Click to view bigger image

    Add/Edit Customer (edit mode shown below 1/2 way through Editing Customer Order)

    Click to view bigger image

    Search Customers

    Click to view bigger image

    How It Is Made

    The general idea behind the demo app is quite a simple one. The following function points explain how it should all work:

    1. The UI will be a tabbed interface that shall start out with a start page pre-loaded
    2. The UI shall support creating a new Customer from both the start page and a MenuItem. In both cases a new tab should be opened, unless an Add/Edit Customer tab is already opened, which is a stupid limit that I artificially imposed just to show off how to work with Mediator and Workspaces
    3. The UI shall support searching of Customers from both the start page and a MenuItem. In both cases a new tab should be opened, unless an Search Customers tab is already opened, which is a stupid limit that I artificially imposed just to show off how to work with Mediator and Workspaces
    4. It should be possible to edit an existing Customer from the search results, unless there is a Add/Edit Customer tab already opened
    5. It should be possible to delete an existing Customer from the search results, unless the selected Customer is already open in a  Add/Edit Customer tab already opened
    6. It should be possible to add a new Customer from the Add/Edit Customer tab, and view any errors using the error styled textboxes on the Add/Edit Customer tab
    7. It should be possible to open an existing Customer (from Search results) and start editing the Customer, and then cancel the edit, which should not only cancel the edit to the Customer, but close the Add/Edit Customer tab
    8. It should be possible to add an Order to an Existing Customer via a popup window, and view any errors using the error styled textboxes on the Add/Edit Order popup window
    9. It should be possible to edit an Order for an Existing Customer via a popup window
    10. It should be possible to open an existing Customers Order (from Customers Orders list) and start editing the Order, and then cancel the edit, which should not only cancel the edit to the Order, but close the Add/Edit Order popup window

    So that's what the UI should do, and guess what it actually does do all of this. So how do we go about covering this little lot?

    Well we have covered it all before, so I think the best thing to do it list the function points above and then I will simply point you at where these things were discussed in previous Cinch articles.

    Demo App Function Points

    Item1

    This is achieved using a TabControl whos items are bound to a ObservableCollection<ViewModelBase> as discussed within this previous Cinch article section:

    CinchIII.aspx#CloseVM

    Item2

    As Item 1, but the checking to see whether there already an open Add/Edit Customer tab is done via the Mediator, as discussed within this previous Cinch article section:

    CinchII.aspx#MediatorMessaging

    Item3

    As Item 2

    Item4

    As Item 2, but the editing of the Customer object is achieved using the IEditableObject interface, as discussed within this previous Cinch article section:

    CinchII.aspx#IEditableObject

    Item5

    As Item 2

    Item6

    This is done by the use of the IDataErrorInfo interface, as discussed within this previous Cinch article section:

    CinchII.aspx#validationRules

    Item7

    The editing of the Customer object is achieved using the IEditableObject interface, as discussed within this previous Cinch article section:

    CinchII.aspx#IEditableObject

    Item8

    The errors are displayed as stated in Item 6 using the IDataErrorInfo interface. Handling the opening of the popup is done using the IUIVizualiserService, as discussed within this previous Cinch article section:

    CinchIII.aspx#PopServ

    CinchIV.aspx#PopServ

    CinchV.aspx#UIVisualizer

    Item9

    The editing of the Customers Order object is achieved using the IEditableObject interface, as discussed within this previous Cinch article section:

    CinchII.aspx#IEditableObject

    Item10

    As Item 7

    What's Coming Up?

    In the subsequent articles I will be showcasing it roughly like this

    1. A code generator for developing quick Cinch ViewModels/Models, and maybe more if I find some more time. The code generator will be written in Cinch so the code generator will also serve as a 2nd example of how to use Cinch in your own projects.

    That's It Hope You Liked It

    That is actually all I wanted to say right now, but I hope from this article you can see how Cinch made the development of the demo app, er well a "Cinch". 

    Thanks.

    As always votes / comments are welcome.

  • License

    This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    About the Author

    Sacha Barber


    Member
    I currently hold the following qualifications (amongst others, I also studied Music Technology and Electronics, for my sins)

    - MSc (Passed with distinctions), in Information Technology for E-Commerce
    - BSc Hons (1st class) in Computer Science & Artificial Intelligence

    Both of these at Sussex University UK.

    Award(s)

    I am lucky enough to have won a few awards for Zany Crazy code articles over the years

    • Microsoft C# MVP 2009
    • Codeproject MVP 2009
    • Microsoft C# MVP 2008
    • Codeproject MVP 2008
    • And numerous codeproject awards which you can see over at my blog

    Occupation: Software Developer (Senior)
    Location: United Kingdom United Kingdom

    Other popular Windows Presentation Foundation articles:

    Article Top
    You must Sign In to use this message board.
    FAQ FAQ 
     
    Noise Tolerance  Layout  Per page   
     Msgs 1 to 25 of 57 (Total in Forum: 57) (Refresh)FirstPrevNext
    GeneralHow to implement application wide undo/redo Pinmembernuno8910:29 18 Oct '09  
    GeneralRe: How to implement application wide undo/redo PinmvpSacha Barber20:24 18 Oct '09  
    QuestionTabControlEx within an UserControl cause problem for displaying first tab PinmemberGautier Boder5:14 16 Oct '09  
    AnswerRe: TabControlEx within an UserControl cause problem for displaying first tab Pinmembereburke5617:09 16 Oct '09  
    GeneralRe: TabControlEx within an UserControl cause problem for displaying first tab Pinmembereburke5617:15 16 Oct '09  
    QuestionThe INSERT statement conflicted with the FOREIGN KEY constraint \"FK_Order_Order\" Pinmemberdrwebmonkey9:58 11 Sep '09  
    AnswerRe: The INSERT statement conflicted with the FOREIGN KEY constraint \"FK_Order_Order\" PinmvpSacha Barber21:32 11 Sep '09  
    GeneralADO.NET Entity Framework Pinmemberm_zayed6:57 10 Sep '09  
    GeneralRe: ADO.NET Entity Framework PinmvpSacha Barber22:38 10 Sep '09  
    GeneralRe: ADO.NET Entity Framework Pinmemberm_zayed3:47 11 Sep '09  
    GeneralRe: ADO.NET Entity Framework PinmvpSacha Barber4:57 11 Sep '09  
    GeneralRe: ADO.NET Entity Framework Pinmemberm_zayed22:58 11 Sep '09  
    GeneralRe: ADO.NET Entity Framework PinmvpSacha Barber23:04 11 Sep '09  
    GeneralI get error when I open MainWindow.xaml PinmemberCuongfdd16:34 2 Sep '09  
    GeneralRe: I get error when I open MainWindow.xaml PinmvpSacha Barber22:46 2 Sep '09  
    GeneralRe: I get error when I open MainWindow.xaml PinmemberStrattonN10:01 29 Sep '09  
    GeneralSolution to : I get error when I open MainWindow.xaml [modified] Pinmembersergezab12:34 17 Nov '09  
    GeneralRe: I get error when I open MainWindow.xaml Pinmembercycleguy10:56 6 Oct '09  
    QuestionCanceled data displayed in views Pinmemberno cars go15:37 1 Sep '09  
    AnswerRe: Canceled data displayed in views PinmvpSacha Barber22:34 1 Sep '09  
    AnswerRe: Canceled data displayed in views PinmvpSacha Barber11:29 2 Sep '09  
    GeneralRe: Canceled data displayed in views Pinmemberno cars go12:23 2 Sep '09  
    GeneralOrders view updated, but customer list view still need refresh Pinmemberno cars go8:26 5 Sep '09  
    GeneralRe: Orders view updated, but customer list view still need refresh PinmvpSacha Barber22:37 5 Sep '09  
    GeneralWrong return command PinmemberMaC_Premium0:50 26 Aug '09  

    General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    PermaLink | Privacy | Terms of Use
    Last Updated: 4 Sep 2009
    Editor:
    Copyright 2009 by Sacha Barber
    Everything else Copyright © CodeProject, 1999-2009
    Web18 | Advertise on the Code Project