Click here to Skip to main content
12,763,515 members (32,606 online)
Click here to Skip to main content


75 bookmarked
Posted 23 Aug 2008

Item-Level Presentation Models for WPF

, 2 Apr 2011 GPL3
Make your life easier by inserting a Presentation Model layer (aka ViewModel) between your domain-model collection contents and template-generated WPF objects.
using System;
using System.Windows;
using System.Configuration;

namespace HappyNomad.Examples.PresentationModel {

	/// <summary>
	/// Interaction logic for App.xaml
	/// </summary>
	public partial class App : System.Windows.Application {
		private static SampleListContainer sampleListContainer;

		public static SampleListContainer SampleListContainer {
			get {
				if ( sampleListContainer == null ) {
					//Build sample domain-model data:
					sampleListContainer = new SampleListContainer();
					Representative obama = new Representative( "Barack Obama" );
					Representative specter = new Representative( "Arlen Specter" );
					Representative clinton = new Representative( "Hillary Clinton" );
					Representative mcCain = new Representative( "John McCain" );
					sampleListContainer.SampleList.Add( obama );
					sampleListContainer.SampleList.Add( specter );
					sampleListContainer.SampleList.Add( clinton );
					sampleListContainer.SampleList.Add( mcCain );
					sampleListContainer.SampleList.Add( new Represented( "Chicago", obama ) );
					sampleListContainer.SampleList.Add( new Represented( "Philadelphia", specter ) );
					sampleListContainer.SampleList.Add( new Represented( "Albany", clinton ) );
					sampleListContainer.SampleList.Add( new Represented( "Phoenix", mcCain ) );
				return sampleListContainer;

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


About the Author

Adrian Alexander
United States United States
Adrian loves facilitating suave user experiences via the latest and greatest GUI technologies such as Windows 8 Metro-style apps as well as WPF. More generally, he finds joy in architecting software that is easy to comprehend and maintain. He does so by applying design patterns at the top-level, and by incessantly refactoring code at lower levels. He's always interested in hearing about opportunities for full or part-time development work. He resides in Pennsylvania but can potentially travel anywhere in the country. (Writing about himself in the third-person is Adrian's new hobby.)

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170217.1 | Last Updated 2 Apr 2011
Article Copyright 2008 by Adrian Alexander
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid