Showing posts with label MVVM. Show all posts
Showing posts with label MVVM. Show all posts

Monday, May 13, 2013

Okay, Okra! Windows Store Templates that make MVVM apps, and pages, easier and quicker

Andy On WPF, Windows 8 and Beyond - Windows Store MVVM Templates for Visual Studio

If you have ever tried to create a Windows Store application using the MVVM pattern then you will probably have found that the Visual Studio project and item templates are a bit cumbersome. I often find myself adding a new page to my projects using one of the default templates, only to need to rewrite it to follow the MVVM pattern before I can even start adding application specific logic. What if there was a way to take advantage of the selection of project and page templates provided by Visual Studio, but have them produce fully MVVM compliant code?

Well today I’d like to announce the release of a free extension for Visual Studio 2012 (including the Express editions for Windows 8) that provides just that. It is based upon the open source Okra App Framework, and provides almost all of the Visual Studio Windows Store templates in an MVVM friendly manner.


What Templates are Provided?

There are two types of template included, project templates and item templates. The project templates are designed to get you started with a new application and provide exactly the same behaviour as the default Visual Studio templates (but written following the MVVM pattern).

  • Okra Basic App - A single-page Okra App Framework project with no predefined controls or layout.
  • Okra Grid App - A three-page Okra App Framework project that navigates among grouped items arranged in a grid. Dedicated pages display group and item details.
  • Okra Split App - A two-page Okra App Framework project that navigates among grouped items. The first page allows group selection while the second displays an item list alongside details for the selected item.


Also included are a number of item templates that allow you to add new pages to any existing Okra App Framework based application, whether created using the project templates or not.

  • Basic Page (MVVM)
  • Split Page (MVVM)
  • Items Page (MVVM)
  • Item Detail Page (MVVM)
  • Grouped Items Page (MVVM)
  • Group Detail Page (MVVM)
  • Search Contract (MVVM)
  • Share Target Contract (MVVM)
  • Settings Pane (MVVM)




As I have discussed the new “Windows Store MVVM Templates for the Okra App Framework” make it quick and easy to implement pages following the MVVM pattern for use in Windows Store applications. The behaviour of all the templates has been designed to be identical to the default Visual Studio templates, with the added benefit of clean separation of code, unit testability and design-time data

Thanks for the heads up on this Andy (and nice work!). I think you're right, that my readers might find this useful. And heck, if they don't I DO! :)


Related Past Post XRef:
The first step in gestating a Metro app... Cocoon

Tuesday, April 23, 2013

The First [12] Steps in using Caliburn Micro to build awesome Windows Phone 8 App's - First steps with Caliburn Micro in Windows Phone 8 – The complete series

This post is simply a collector of all the blog posts I wrote about using Caliburn Micro, a very powerfull Model-View-ViewModel framework, in Windows Phone 8. The posts are listed in chronological order, so it will be easier for you to follow the logic path of the posts: from the basic concepts (what’s Caliburn, conventions, etc.) to the most complex stuff (tombstoning, collections, messaging).

This list will be published also at the bottom of every post of the series, so that it will be easier for you to jump from a post to another.



Caliburn Micro is one of my favorite MVVM frameworks and I'm really starting to fall in love with my Windows Phone 8, so highlighting this just seems natural, doesn't it? :)


Related Past Post XRef:
Caliburn.Micro v1.5.0 released (CM gets Tasks, Async/Await and Share/Setting for RT... and bug fixes of course)
Callisto + Caliburn.Micro + these Dialog Helpers = Happy Windows RT Dev Camper
Caliburn.Micro RTW’s (Think a”Lighter/smaller/micro MVVM Framework for WPF, WP7 & Silverlight)
Doing WPF/SilverLight? Interested in presentation patterns like MVVM, MVC? Testing/TDD friendly development? Solutions to common UI architecture problems? Then Caliburn might just be for you

Tuesday, March 19, 2013

Caliburn.Micro v1.5.0 released (CM gets Tasks, Async/Await and Share/Setting for RT... and bug fixes of course)

Caliburn.Micro - Caliburn.Micro v1.5.0

"Release Notes

This release fixes many bugs. It also adds support for Task and async/await functionality, including integration with co-routines. For WinRT, we now have built-in support for the Share and Settings charms.

Packages Available on Nuget

  • Caliburn.Micro – The full framework compiled into an assembly.
  • Caliburn.Micro.Start - Includes Caliburn.Micro plus a starting bootstrapper, view model and view.
  • Caliburn.Micro.Container – The Caliburn.Micro inversion of control container (IoC); source code drop-in.
  • Caliburn.Micro.EventAggregator – The Caliburn.Micro event aggregator; source drop-in.
  • Caliburn.Micro.INPC – The Caliburn.Micro INPC infrastructure: PropertyChangedBase, BindableCollection, Execute.OnUIThread and InDesignMode checking; source drop-in.


Caliburn.Micro is one of my MVVM Frameworks of choice, so a new release is good news for me... In some cases CM is just magic and makes MVVM pretty darn easy and seamless.

Monday, February 25, 2013

Windows 8 + Kona + Steve = Itinerary Hunter

#WINNING with C# - Windows Store App Example: Itinerary Hunter


Using KONA as a framework, you can think of KONA as the Windows 8 equivalent of PRISM, I have created a Windows Store App for Itinerary Hunter.

The solution features distinct projects for UI views, UI logic (view models, converters, etc), services and tests.  Interfaces are used throughout to enable mocking for unit tests.

Here’s some screenshots of the app



stevenh77 / ItineraryHunter-Win8


I've not seen to many examples yet of Kona based apps, so when I saw this I wanted to make sure to highlight it...


Related Past Post XRef:
Kona, Kona, Kona! [Think P&P dev guidance for composite application WinStore Apps {Yes, like Prism, but not}]

Thursday, February 07, 2013

Intro to MVVM in four easy episodes....

CodeProject - MVVM # Episode 1 (2, 3 & 4)


MVVM seems, to me, to be the best way to develop applications that are both flexible - allowing changes to the GUI without complex rewrites, and allowing testing of the client logic without needing to resort to complex macros.

In this series of articles, I will present a small application in WPF, using an enhanced MVV pattern that I'm calling MVVM#.

So, what's different about my implementation? The main things are:

  • Message Tracking: When a message is sent, we now know if it has been handled.
  • Cancellable messages: A ViewModel can stop the message being sent further down the chain.
  • Easy Peasy Modal Dialog windows
  • No 'Main window': Everything is a View.
  • Use of a Controller: The Controller controls the application.
  • Easy to use Design Time Data for 'Blendability'
  • Use of ViewData for binding data to a View, as well as a ViewModel to bind behaviour to a view.

In this article, I introduce the topics, and ideas, and explain some of the differences.

In the second article, I'll show the way I set up any project using MVVM#, creating the base classes ready to begin the application specific development.

In the third article, I'll add sufficient meat to the bones created in article 2 to give us a running application, albeit one that doesn't do too much.

In the fourth article, I'll finish off the application to show a (small) but functioning application demonstrating some of the functions available.


I've been looking at MVVM for a while now, without the opportunity to develop real applications using the pattern. I've downloaded and looked at most of the various frameworks, and even understood a few! But I don't like using a framework when I am learning something new - I want to understand the subject from the ground up. So I started playing, developing my own application using MVVM, and re-engineering to surmount the many obstacles I encountered.

In this article, I will describe some of the thought processes that drove me to extend the MVVM pattern, and introduce that pattern.

In the next article in this series, I will walk through developing an application from scratch, in VS2010 using C#, to implement this pattern.

Points of Interest

Man! It's a minefield out there!

There are so many articles, written by the extremely knowledgeable through to the novices, and it is really hard to sort the wheat from the chaff. Debts are due to the WPF Disciples in general, Josh and Marlon in particular, and especially Pete Hanlon who has responded to my often cryptic questions on CodeProject with never a groan! Thanks also go to any of the many people out there in etherland who have helped me, knowingly or not, to develop this series. Isn't it amazing how much free help there is out there? Hopefully, this series will help me give a little back.


If you're trying to wrap your head around MVVM, this article series might help a bit. It's one mans implementation of MVVM, but it sounds like he's "been there, done that" and the article reflects some real world lessons learned. The thing with MVVM is that there seems to be about a billion ways to do it, and until there's an official implementation/guidance in the box,. there's going to continue to be. And while that's kind of neat, it's also a major pain in the butt when you're trying to get up speed on it ...

Anyway, this series provides one of the billion ways. And if this works for you, then you can ignore the other 999,999,999 for now... :)

Monday, January 07, 2013

Kona, Kona, Kona! [Think P&P dev guidance for composite application WinStore Apps {Yes, like Prism, but not}]

Infragistics - Introducing Kona Guidance for Windows 8 Application Development (Think of it as Prism for Windows 8, but not really)

I am extremely excited to announce a new project from the smart people at Microsoft’s Patterns & Practices team called Kona.  What is Kona you ask?  Kona is the new developer guidance for developing line of business applications for Windows 8.  Initially this project was called Prism for WinRT, but as it turns out, it’s really not Prism running on Windows 8, but rather a new set of guidance for developing Windows 8 applications.

Wait… just... a... minute Brian.  What do you mean it’s not “Prism” running on Windows 8?  What do you mean “new guidance”?  Well, if you download Kona and expect to start adding regions and modules like you’re used to, then you might get a bit frustrated looking for the attached properties and IModule interface.  Why?  Well, because it’s not there!  Actually there is a lot of Prism code that you are used to having that is not there and will not be there.  Why do you ask?  The answer is simple; it’s Windows 8.  Huh!?  It’s a new platform, and it has changed significantly compared to WPF and Silverlight.  When they were looking at doing the “port” of Prism, they soon realized that a lot of capabilities just didn’t make sense to bring over to the new platform.  Hence, a new set of guidance using a new set of APIs that are specific to the new Windows 8 platform.

Now not everything was ditched.  Some things, not a lot, made sense to bring over.  DelegateCommand and DelegateCommand<T> is still there.  Guidance on MVVM (Model-View-ViewModel) is still there, but honestly I don’t agree with the implementation.  Keep in mind, this is the first initial drop of Kona, so we can always make improvements to the code base.  Everything is a learning experience.






Interesting. Brian's post is much more complete that you'll find yet on the codeplex page,, but as he said, this is just the first drop... Will be watching for this now though... :)

Friday, October 26, 2012

Sacha Barber shares his WPF/RavenDB/MVVM Diagram Designer application

CodeProject - MVVM Diagram Designer



A while back a user called "sucram (real name Marcus)"  posted a series of articles here about how to create a diagram designer using WPF. Sucrams original links are as follows:

I remember being truly blown away by this series of articles, as they showed you how to do the following things:

  • Toolbox
  • Drag and Drop
  • Rubber band selection using Adorners
  • Resizing items using Adorners
  • Rotating items using Adorners
  • Connecting items
  • Scrollable designer surface, complete with zoombox

WOW that sounds fantastic, sounds exactly like the sort of things you would need to create a fully functional diagram designer. Well Yeah, its was and still is, but........the thing is I have used WPF a lot, and trying to use the code attached to sucrams series of article in WPF just wasn't that great. He had taken a very control centric view, in that everything was geared around adding new controls and supplying static styles for said controls.

In reality it was more like working with a Win Forms application. Not that there is anything wrong with that, and I really truly do not mean to sound ungrateful, as that could not be further from the truth, without that original series of articles it would have taken me a lot longer to come up with a working diagram designer that I was happy with. So for that I am truly grateful, thanks sucram you rock.

Anyway as I say sucrams original codebase took a very control centric point of view, and added controls using code behind, and held collections of items directly in the diagram surface control. As I say if that is what you want cool, however, it was not what I wanted. What I wanted was

  • All of the features of curams original code (actually I didn't want any rotating of items, or resizing of items)
  • A more MVVM driven approach, you know allow data binding of items, delete of items via ICommand etc. etc.
  • Allow me to control the creation of an entire diagram from within a single ViewModel
  • Allow for complex objects to be added to the diagram i.e. ViewModels that I could style using DataTemplate(s). Sucrams original code only allowed simply strings to be used as a DataContext which would control what ImageSource an Image would use to show for a diagram item. I needed my items to be quite rich and allow popups to be shown and associated with the diagram item, such that the data related to the diagram item could be manipulated
  • Allow me to save the diagram to some backing store
  • Allow me to load a previously saved diagram from some backing store

To this end I have pretty much completely re-written sucrams original code, I think there is probably about 2 classes that stayed the same, there is now more code, a lot more, however from an end user experience, I think it is now dead easy to control the creation of diagrams from a centralized ViewModel, which allows a diagram to be created via well known WPF paradigms like Binding/DataTemplating.

For example this is how the attached DemoApp code creates a simple diagram that is shown when you first run the DemoApp:


What Does It Look Like

This is quite interesting, as if you look at the screen shot below and compare that to the final article that sucram produces you probably won't see any difference, which as I previously stated was intentional. I think sucram really nailed it, I just wanted a more WPF style codebase, one that supported Binding etc. etc., so yeah I must admit you could easily look at this screen shot and think "Bah humbug......this is exactly the same", well yes visually speaking I guess it is, however the code is very very different, and the way in which you work with the diagram is very different. Anyway enough chat here is a screen shot.



This project is a demonstration project, and is a good example of how to create your own diagram designer. It is a fully functioning demo, and also demonstrates persisting/hydrating using RavenDB which is a NoSQL document database (as I could not be bothered writing loads of SQL)

Persistence common classes, used by DemoApp

I decided to use RavenDB for persistence which is a NoSQL database, that allows raw C# objects to be stored. I decided to do this, as I really couldn't be bothered to create ALL the SQL to save/hydrate diagrams, and I just wanted to get something up an running ASAP
Though if you use SQL server/MySQL etc. etc., it should be pretty easy to create the stored procedures/data access layer that talks to your preferred SQL database.

This project contains the core classes that are needed to create a diagram in WPF

How Do I Use It In My Own Applications

This section will talk you through how to create a diagram in your own application. It assumes the following

  • That you want to use WPF things like Binding/DataTemplating/MVVM
  • You actually want to persist / hydrate diagrams to some backing store (Like I say I chose to use RavenDB which is a no sql document database, but if this is not for you, it should be pretty easy for you to craft your own data access layer talking to your preferred SQL backend)

If you want to create your own MVVM style diagram designer, I have broken it down into 7 easy steps, as long as you follow these 7 steps to the letter you should be just fine. There is also a working example of these 7 steps by way of the attached DemoApp project code, so you can examine that whilst reading this text, so hopefully you will be ok.

Use It Step 1 : Creating The Raw XAML


Have you clicked through yet? Have you seen the depth and how long this article is? Yeah, wow.

I dig that he used RavenDB. I've been following that product but never used it (or think I've seen in used in a sample/demo I've downloaded). Then of course there's the MVVM goodness and everything else he's showing off. This should keep you code-geeking for a while...:)

Thursday, October 25, 2012

Take two [AvalonDock 2.0 Tutorials] and call...

CodeProject - AvalonDock [2.0] Tutorial Part 1 - Adding a Tool Window

"AvalonDock was written by Adolfo Marinucci. I am in no way involved with the development of AvalonDock but felt that it was time to document some essential things. I am not sure whether I got everything completely right (since I am not the primary developer) but I am building on some experience and simply hope people will give me feedback here if I am making claims that are false.

The first two parts of the tutorial are covering initial preperation steps and adding a Most Recent Files (MRU) tool window and a Start Page. There may be more parts on other AvalonDock subjects (theming, localization, AvalonEdit in AvalonDock 2.0) later. Those who cannot wait for later articles shall look at Edi ( to see some of the things before I document them here. This article was in fact written with Edi.

Solution Preparation

  • Download AvalonDock sources from CodePlex (I used build 96566)
  • Find the version 2.0 Sub-folder and remove all other sub-folders
  • Review the solution in the version 2.0 sub-folder and remove all
    test projects except for AvalonDock.MVVMTestApp
    I ended up removing the sub-projects:
    and was left with:
    AvalonDock (docking layout system library)
    AvalonDock.Theme.VS2010 (theming resources library)
    AvalonDock.Themes.Aero (theming resources library)
    AvalonDock.MVVMTestApp (Test apllication to be extended in this article)
  • Add a new WPF Application project with the application name that you want to develop based on AvalonDock (mine is Edi) and copy files from AvalonDock.MVVMTestApp into the new project. I also resorted some items into folders and namespaces as you can see if you review Your solution should look something like this:

Lets get down to Business

Open the solution and set the Edi project as Startup Project in Visual Studio. Hit the F5 key to check that the application runs OK. I have seen the following content in my case:




CodeProject - AvalonDock [2.0] Tutorial Part 2 - Adding a Start Page


This part of the tutorial, explains how we can add a Start Page to an application that is build on AvalonDock [2.0]. There may be more parts on other AvalonDock subjects (theming, localization, AvalonEdit in AvalonDock 2.0) later. Those who cannot wait for later articles shall look at Edi ( to see some of the things before I document them here. This article was in fact written with Edi.

This article is based on the solution that is described in the previous part 1. We are going to extend the solution in the file attached to the previous article. Therefore, it may be useful to download the file and the attached to this article - since comparing both versions highlights all things that are necessary to implement the Start Page described here.

So lets have a look at the solution in the container.

The ViewModel

The first thing to note is the Edi.ViewModel.StartPageViewModel and the Edi.View.StartPage classes which are both introduced to implement the viewmodel and view of the Start Page item. We also note a new base ViewModel class of the FileBaseViewModel type which is introduced to give the document viewmodels, FileViewModel and StartPageViewModel, a common root. This common root is necessary because the document collection is stored in the Workspace viewmodel:



Is it lame that after all this time I've still not used this awesome component in anything but a quick and dirty play-with app?  I'm green-fielding some WPF app's now, so maybe...  hum...


Related Past Post XRef:
THE open source WinForm & WPF docking library gets overhauled and a new version two, AvalonDock v2's!
AvalonEdit, a (the?) WPF code editor component from the SharpDevelop team (think WPF based, monster cool, code editing, IDE like, uber textbox +10)
Working Workflow into your app's. Workflow Studio, a source available example of rehosting the Workflow Designer

Monday, October 15, 2012

Callisto + Caliburn.Micro + these Dialog Helpers = Happy Windows RT Dev Camper

Mikael Koskinen - Callisto Dialog Helpers for Caliburn.Micro WinRT

Callisto is excellent open source UI Control library for the Windows 8 Store apps. Caliburn.Micro is a powerful framework for building Windows Phone, Silverlight and Windows 8 Store apps. These helpers make it easies to combine Caliburn.Micro with the Callisto's dialogs.


  • Helper for displaying settings dialogs on the Settings charm
  • Helper for displaying normal dialogs all around the screen


The helpers are available as a source code through NuGet:

Install-Package CaliburnMicroWinRTCallistoHelpers

Installing the package will add a Dialogs-folder into your project. This folder contains the source code for the helpers.



This combination looks like a great way to streamline WinRT dev and avoid re-inventing the wheel, letting you focus on what's important, your app...


Related Past Post XRef:
Caliburn.Micro RTW’s (Think a”Lighter/smaller/micro MVVM Framework for WPF, WP7 & Silverlight)

Something for your Metro style app building utility belt, the Callisto toolkit
TWC9: Build sold out, Portable Class Library, eBooks galore, SQLite, WinRT and more

Friday, October 12, 2012

proprt... A C# snippet to speed up the writing of Windows 8/MVVM Properties

The Brain Dump - Windows 8 ViewModel Property Code Snippet

Visual Studio provides a bunch of good code snippets for creating boilerplate code. For example if you type “prop” you get this in intellisense


You’ll see a few nice property snippets.

  • prop – creates a basic automatic property
  • propa – creates an attached property
  • propdp – creates a dependency property
  • propfull – creates a public property with a private backing field
  • propg – creates a basic automatic property but the set is marked private

I use these constantly but hit an issue when building my Windows 8 apps. For ViewModels in Windows 8, the default templates take advantage of a wonderful attribute CallerMemberName in the OnPropertyChanged method of the ViewModel base class. This allows you to create properties that support notifications in a very simple manner. Like this




Funny... I was just looking for something like this. I love the inter-tubes...

Wednesday, October 10, 2012

Navigation, MVVM, XAML and a little IG (Infragistics) in this "Building IG Outlook" video - Building IG Outlook Part 5–Implementing Navigation and MVVM


This is the fifth video in a series that will take you step-by-step on building a Prism application that mimics Microsoft Outlook.  In this video, we implemented our navigation using the Prism navigation APIs as well as some navigation objects we created to provide our navigation path.  We talked a little about INavigationAware interface, IConfirmNavigationRequest interface, and how the View and ViewModel can participate in the Prism navigation process.  DelegateCommand and CompositeCommand were also discussed.  We also implemented our own little MVVM framework which is made up of only two interfaces, IViewBase and IViewModel.  You saw the first glimpse of the EventAggregator and much more.  Wow, we really covered a lot in this video.  Of course we only had time to implement this functionality in the Silverlight version of the application.  So, I went ahead and implemented the same functionality in the WPF version as well.  ..."

I'm in a place now were I can really start working on modern applications (i.e. model based, WPF, MVVM, etc) so I'm now keeping an even sharper eye out for related materials, posts, etc, like this...

Friday, September 14, 2012

Meaning to MVVM (but haven't yet?) Here's a crash course... "Easy MVVM examples (in extreme detail)"

Microsoft Developer Network - Easy MVVM Example

"This project will give you crash course on WPF MVVM that you can do in your lunch break! Everything you need to know about binding, INotifyPropertyChanged, Dependency Objects & Properites, POCO objects, Business Objects, Attached Properties and much more!


Easy MVVM examples (in extreme detail)

This article discusses the various methods and tricks used in MVVM to enable a developer to completely separate the user interface from the code.

Table of Contents


Model View ViewModel is the golden child of WPF, allowing a developer to completely separate their application code from any UI dependencies.

This means an application can be easily be re-skinned and it also makes an application much easier to test.

The View represents any front-end user interface controls (Window, Page, UserControl), the model represents the classes used in the application, and the ViewModel is the middle-man that requests, molds and exposes the data, as properties and commands.

This is article is linked to a TechNet sample project that you can download and explore. It covers many basic concepts of MVVM, and some of the common pitfalls and solutions.


This is one of those helper articles for those that have been meaning to look into/learn/grok MVVM but haven't yet found the time too...

Tuesday, July 10, 2012

MVVM Light Toolkit v4 RTM's

MVVM Light Toolkit - MVVM Light Toolkit V4 RTM

This version supports Silverlight 3, Silverlight 4, Silverlight 5, WPF 3.5 SP1, WPF4, Windows Phone 7.0 and 7.5, WinRT (Windows 8).

Support for Visual Studio 2010 and Visual Studio 2012 RC.

MVVM Light Toolkit

Project Description

The MVVM Light Toolkit is a set of components helping people to get started in the Model - View - ViewModel pattern in Silverlight and WPF. It is a light and pragmatic framework that contains only the essential components needed.

Get started

More information about the MVVM Light Toolkit can be found on


Galasoft - MVVM Light Toolkit

The main purpose of the toolkit is to accelerate the creation and development of MVVM applications in WPF, Silverlight and in the Windows Phone.

Like other MVVM implementations, the toolkit helps you to separate your View from your Model which creates applications that are cleaner and easier to maintain and extend. It also creates testable applications and allows you to have a much thinner user interface layer (which is more difficult to test automatically).

This toolkit puts a special emphasis on the "blendability" of the created application (i.e. the ability to open and edit the user interface into Expression Blend), including the creation of design-time data to enable the Blend users to "see something" when they work with data controls.

Much has been written about MVVM as a pattern. I recommend starting with the following:

Installation and Creation

The MVVM Light Toolkit installation procedure is described here.

To create a new MVVM Light application, check this article (for Visual Studio) and this one (for Expression Blend).


I don't think I've Laurent's MVVM Light Toolkit before (at least not directly). Given this is the v4 RTM, I think it's about time I do...


Related Past Post XRef:
SilverLight 4, RIA Services, MEF and MVVM, oh my… A four part series from the mind of Shawn Wildermuth (updated for VS2010/SL4 RTM)

Thursday, May 03, 2012

From Code-Behind to MVVM, a three part series...

CodeProject - Migrate from Basic to MVVM and MEF Composable Patterns for a Silverlight Application - Part 1


One of my previous posts shows a simple demo application that uses a WCF RIA Services class library with the code first domain data service for CRUD data operations. There are a main screen and a child window with basic navigation and code-behind patterns. What happens if we upgrade the application to that with the MVVM and MEF composable patterns? How easy are the approaches? What are the details of the coding? The article series will address the questions with the easiest approaches and detailed coding explanations. The application, after completed, will not be a full-fledged sample, but should include all major aspects regarding the MVVM and MEF composable pattern implementation without focusing on some other areas such as the UI, data validations, data service operations, or security. I'll also describe how to handle the popup child window with the new patterns, perform the composable part clean-up, and persist the state when switching screens in pure MVVM styles.



CodeProject - Migrate from Basic to MVVM and MEF Composable Patterns for a Silverlight Application - Part 2

"In the Part 1 of the article series, we have started the work on changing to MVVM and MEF composable patterns for a Silverlight application previously with basic navigation and code-behind patterns. By the end of the Part 1, the application is capable of loading a xap, exporting a class module to the composition container, and rendering the same screen to the browser as that before the changes. We will implement the composable MVVM modules for the MainPage user control, the Product List parent screen, and the child window in this part based on the architecture design shown from the beginning of the Part 1.

Contents and Links


CodeProject - Migrate from Basic to MVVM and MEF Composable Patterns for a Silverlight Application - Part 3

"After completing the work described in the previous parts of article series, we have created the main content holder project and upgraded the Product List screen with its child window from basic patterns to the MVVM and MEF composable patterns. In this part, we'll add another demo screen into the ProductApp.Main project and create another set of projects in the solution for a new xap assembly so that we can switch screens between exported modules and xap assemblies. We'll then implement the module clean-up processes and add the state persistence feature into the application.

Contents and Links


While this was targeted at a SilverLight application, there's lessons here for anymore moving a WPF/XAML app from code-behind to MVVM.

Wednesday, May 02, 2012

Wave hello to WAF - WPF Application Framework

CodePlex - WPF Application Framework (WAF)

"The WPF Application Framework (WAF) is a lightweight Framework that helps you to create well structured WPF Applications. It supports you in applying a Layered Architecture and the Model-View-ViewModel (aka MVVM, M-V-VM, PresentationModel) pattern.



  • WPF Application Framework (WAF)
    • ViewModel: Contains types that help you to implement the Model-View-ViewModel Pattern.
    • DataModel: A base class supports you in applying the DataModel-View-ViewModel Pattern.
    • DelegateCommand: The DelegateCommand allows you to handle WPF commands in other classes than the View.
    • INotifyPropertyChanged: The base classes implement the INotifyPropertyChanged interface. The implementation checks the property name in DEBUG mode.
    • WeakEvent: First class support for the WPF WeakEvent Patterns which helps you to avoid memory leaks.
    • Validation: The DataErrorInfoSupport class brings the IDataErrorInfo interface with the DataAnnotations validation framework together.
    • ConverterCollection: This collection is able to keep the DataModels synchronized with an ObservableCollection of Models.
    • Services: Provides services to show a message or the open/save file dialog to the user.
    • Recent Files: The RecentFileList class provides the logic for a recent file list that can be loaded and stored in the application settings.
  • Unit Testing Extensions
    • Exceptions: The ExpectedException method test if an action results in a specified exception.
    • PropertyChanged: Provides a helper method to test if a property changed event is raised when a specific action is executed.
    • CanExecuteChangedEvent: A helper method to test if a CanExecute changed event is raised when a specific action is executed.
  • Samples
    • Email Client: A simple Email Client application that shows how to use the M-V-VM Pattern in a wizard oriented application.
    • Writer: A word processing application which uses a “tabbed MDI” as user interface. This sample shows how to use the Message and FileDialog service.
    • Book Library: Shows how to use the Entity Framework and Validation together with the MVVM pattern.
    • Localization: Demonstrates a simple way to localize a WPF application.


While there's a number of MVVM frameworks available, I thought this one interesting and one I'd like to look deeper into. It's funny what grabs you when you scan a page. In this case, it was the Recent Files class. I hate re-inventing MRU lists (having just done one recently)

Thursday, April 05, 2012

"Everything you wanted to know about databinding..." series (Know it, live it, data bind it...)

ScottLogic - Colin Eberhardt- Everything you wanted to know about databinding in WPF, Silverlight and WP7 (Part One)

"OK, so the title is a little ambitious, but there is nothing wrong with setting yourself lofty aims! Because of the depth of this topic I have decided to split this tutorial up into a series of blog posts, each of which explore a different aspect of the binding framework.

I don’t usually write tutorial blog posts and series, preferring instead to develop new controls or novel techniques. However, I really felt this subject needed an in-depth tutorial. Databinding is a fundamental part of the WPF, Silverlight and the Silverlight for Windows Phone 7 frameworks. It is a powerful concept that once mastered allows you to write concise and elegant code. Yet for all its power, it is a little complex and that is my reason for launching into this blog series.

The rough outline for this series is as follows:

  • Part One – Life before binding, INotifyPropertyChanged and creating bindings in code-behind
  • Part Two – The binding markup extensions, the DataContext and path syntax
  • Part Three – Other binding sources, ElementName, TemplatedParent, TemplateBinding
  • Part Four – Value converters
  • Part Five – List binding


Having recently jumped back into the WPF world for some personal utility app building, I'm again humbled on just how little I know (or have to relearn). You all know that if you WPF (or Silverlight or XAML) and you're not data binding, then you're doing it wrong. Code behind needs to be left behind if at all possible. Sure for the uber-simple app's, it's okay. And for the initial prototype, to get something working it's okay (but watch the techdebt), but there comes a time in the app where the complexity will screen for data binding, separation of concerns, some kind of model, like MVVM. You'll know when that time comes, I'm sure. but the key is building it right'er earlier if you can.

Anyway, this looks like a great series and one I'll be following closely.

Tuesday, April 03, 2012

Windows Phone Developer Guidance Updated. Building WinPhone7.1/5 apps with MVVM, that are testable and more...

Francis K. Cheung - SHIPPED!!! Windows Phone Developer Guidance updated for Mango (WP SDK 7.1)

We dramatically updated our guidance around Windows Phone development. Beyond recompiling our previous guidance against the Mango SDK, the latest guidance takes advantage of many Mango features such as fast app switching, background tasks, and new sensor APIs. We also did a fair amount of work showing how to create a layer of abstraction on top of the Windows Phone APIs that facilitates unit testing.

We split up our guidance into three parts:

  1. Developing a Windows Phone Application using the MVVM Pattern
    This guidance walks you through building a simple Windows Phone application using CodeBehind files. The guidance then shows you how the same app can be much more unit testable when built using the MVVM pattern.
  2. A Case Study for Building Advanced Windows Phone Applications
    This guidance takes an in-depth look at how to write an advanced Windows Phone application, using many features of Mango. Unit testability was an important factor that guided the design of this application.
  3. Building Testable Windows Phone Applications
    Taking the work on unit testability from the above guidance, this guidance provides shorter samples of how to build unit testable Windows Phone applications.

..." [GD: Post Leach Level 99%]

Developing a Windows Phone Application using the MVVM Pattern

This documentation and accompanying sample application will get you started building easily testable applications that target Windows® Phone OS 7.1. You will learn the basics of the Model View View-Model (MVVM) pattern and dependency injection through a sample application that enables you to track the petrol consumption of three vehicles. The sample application is authored two different ways so that you can see the progression from a code-behind implementation to a view model implementation whose dependencies are injected.

Some of the topics that you will learn about include the following:


A Case Study for Building Advanced Windows Phone Applications

Windows® Phone provides an exciting opportunity for companies and developers to build applications that travel with users, are interactive and attractive, and are available whenever and wherever users want to work with them. The latest release of Windows Phone furthers this opportunity by enabling you to build many classes of applications that were not previously possible.

By combining Windows Phone applications with on-premises services and applications, or remote services and applications that run in the cloud (such as those using the Windows Azure™ technology platform), developers can create highly scalable, reliable, and powerful applications that extend the functionality beyond the traditional desktop or laptop, and into a truly portable and much more accessible environment.

This guide describes a scenario concerning a fictitious company named Tailspin that has decided to embrace Windows Phone as a client device for their existing cloud-based application. Their Windows Azure-based application named Surveys is described in detail in a previous book in this series, Developing Applications for the Cloud on the Microsoft Windows Azure Platform 2nd Edition. For more information about that book, see the page by the same name on MSDN® at (

In addition to describing the client application, its integration with the remote services, and the decisions made during its design and implementation, this book discusses related factors, such as the design patterns used, and the ways that the application could be extended or modified for other scenarios.

Some of the topics that you will learn about in this guide include the following:

  • Using the MVVM pattern
  • Displaying user interface notifications
  • Managing state and performing navigation
  • Encrypting and decrypting credentials
  • Persisting data to and from isolated storage
  • Synchronizing data between a Windows Phone device and a cloud service, both in the background and the foreground
  • Pinning Application Tiles and secondary Tiles to Start
  • Capturing location data, image data, and audio data
  • Authenticating with a cloud service from a Windows Phone application
  • Pushing notifications to Windows Phone devices
  • Transferring data between a Windows Phone device and a cloud service
  • Abstracting the Windows Phone 7.1 SDK
  • Unit testing MVVM applications

The result is that, after reading this book, you will be familiar with how to design and implement advanced applications for Windows Phone that take advantage of remote services to obtain and upload data while providing a great user experience on the device.




Building Testable Windows Phone Applications

"This documentation and accompanying sample applications will show you how to build easily testable applications that target Windows Phone OS 7.1.

Some of the topics that you will learn about include building testable Windows Phone applications that:


This documentation and accompanying sample applications are best suited for developers with the following experience levels.

Some experience with:

  • C#
  • Silverlight
  • Windows Phone 7.0 or 7.1 SDK
  • The Model-View-ViewModel (MVVM) pattern

Little or no experience with:

  • Building testable Windows Phone applications




Some light reading for the week...

Friday, March 02, 2012

Microsoft Patterns and Practices group helps us build WP7 apps that are testable, MVVM and shares an "Advanced App Case Study"...

Microsoft Patterns and Practices Phone Development Center


How do you build applications targeting the latest generation of Windows Phone 7 handsets?

Smartphones are advanced computing devices that allow users to install and use advanced applications that capitalize on the features of that specific device. Although developing applications for phone-based devices was once a specialized skill, today developers are able to use their existing desktop skills and familiar desktop tools to create smartphone applications.

Active Releases


Microsoft Patterns and Practices Phone Development Center - Developing a Windows Phone Application using the MVVM Pattern


Microsoft Patterns and Practices Phone Development Center - A Case Study for Building Advanced Windows Phone Applications


Microsoft Patterns and Practices Phone Development Center - Building Testable Windows Phone Applications


Some cool and useful guidance and information the MS P&P team for WP7 dev... I

(via  Chris Koenig - P&P Windows Phone Guidance Released)

Monday, January 23, 2012

INotifyPropertyChanged for the VB Control Creating Guy

Visual Studio Magazine - Integrating with the .NET Framework UI Controls

"The .NET Framework team obviously assumes you'll build your applications and the classes that make up your application a certain way. If you leverage those assumptions you'll get lots of cool benefits (and, if you don't leverage those benefits…well, you'll get to do a lot more work).

For instance, the user interface controls you can drag onto your WPF or Silverlight forms (TextBoxes, DropDownList, and so on) assume that you'll bind class properties to them. Those controls look for specific features in your classes; if you build those features into your code, you'll get a lot of functionality for free. The benefit is that you can build those objects independent of your UI, which supports automated testing, parallel development and loose coupling between application components.

One example of how you can integrate your classes with a XAML UI is the INotifyPropertyChanged interface. Adding this interface (and some code) to your classes gives you some almost magical benefits. For instance, if you have an object whose property is bound to and displayed in some user interface control, the control will automatically update in your user interface if you update the property from code. There's no need to do anything to make the user interface display the property's latest value: you don't need to update the control or call a Refresh method on the control (or the form).

Adding the INotifyPropertyChanged interface to your class is easy:



Good to see VB get a little love. I also like the re-use message... (i.e. how components let you DRY, help the S in SOILD, etc)

Wednesday, January 18, 2012

Comfortably numb... MVVM'ing Enums in ComboBox

The Angry Programmer - MVVM ComboBox with Enums

"I decided to write an MVVM version of binding enum values to a ComboBox for WPF. I know there are lots of examples of how to put enum values into combo boxes, but most of them either use ObjectProvider or derive their own class from ComboBox. I don’t like inheritance, I prefer extending classes, as it keeps things cleaner and lets you choose whether to use the facility or not.

To that end, I have come up with a behaviour to populate the ComboBox with enum values.

We’ll start off with the enum I’m going to use called JobTitles.



This is something I have to fight with from time to time and I liked seeing a different approach to solving this.