Click here to Skip to main content
15,892,537 members
Articles / Mobile Apps / Windows Phone 7

Presentation Patterns for XAML based Applications

Rate me:
Please Sign up or sign in to vote.
4.99/5 (44 votes)
17 Sep 2013CPOL23 min read 95.4K   1.5K   176  
Design patterns on the presentation layer for WPF, Silverlight and Windows Phone applications.
// -- FILE ------------------------------------------------------------------
// name       : App.Desktop.cs
// project    : Itenso Community
// created    : Jani Giannoudis - 2012.05.05
// language   : c#
// environment: .NET 4.0
// copyright  : (c) 2004-2012 by Itenso GmbH, Switzerland
// --------------------------------------------------------------------------
using System;
using System.Windows;
using Itenso.Community.XamlPatterns.Collection;
using Itenso.Community.XamlPatterns.Program.Examples.AssemblyBrowser.ViewModel;
using Itenso.Community.XamlPatterns.Program.Examples.ListBoxBinding.ViewModel;
using Itenso.Community.XamlPatterns.Program.Examples.CustomerAdmin.ViewModel;
using Itenso.Community.XamlPatterns.Program.Examples.GridViewBinding.ViewModel;
using Itenso.Community.XamlPatterns.Program.Examples.MediaPlayer.ViewModel;
using Itenso.Community.XamlPatterns.Program.Examples.OrderBrowser.ViewModel;
using Itenso.Community.XamlPatterns.Program.Examples.Selection.ViewModel;

namespace Itenso.Community.XamlPatterns.Program
{

	// ------------------------------------------------------------------------
	public partial class App
	{

		// ----------------------------------------------------------------------
		public MediaPlayerModel MediaPlayer
		{
			get
			{
				return mediaPlayer ?? ( mediaPlayer = new MediaPlayerModel
																							{
																								Source = new Uri( "Videos\\SampleVideo.wmv", UriKind.Relative )
																							} );
			}
		} // MediaPlayer

		// ----------------------------------------------------------------------
		public ListBoxBindingModel ListBoxBinding
		{
			get { return listBoxBinding ?? ( listBoxBinding = new ListBoxBindingModel() ); }
		} // ListBoxBinding

		// ----------------------------------------------------------------------
		public GridViewBindingModel GridViewBinding
		{
			get { return gridViewBinding ?? ( gridViewBinding = new GridViewBindingModel() ); }
		} // GridViewBinding

		// ----------------------------------------------------------------------
		public SelectionModel Selection
		{
			get { return selection ?? ( selection = new SelectionModel() ); }
		} // Selection

		// ----------------------------------------------------------------------
		public CustomerAdminModel CustomerAdmin
		{
			get { return customerAdmin ?? ( customerAdmin = new CustomerAdminModel( ViewSyncMode.Asynchronous ) ); }
		} // CustomerAdmin

		// ----------------------------------------------------------------------
		public AssemblyBrowserModel AssemblyBrowser
		{
			get { return assemblyBrowser ?? ( assemblyBrowser = new AssemblyBrowserModel() ); }
		} // AssemblyBrowser

		// ----------------------------------------------------------------------
		public OrderBrowserModel OrderBrowser
		{
			get { return orderBrowser ?? ( orderBrowser = new OrderBrowserModel() ); }
		} // OrderBrowser

		// ----------------------------------------------------------------------
		protected override void OnStartup( StartupEventArgs e )
		{
			base.OnStartup( e );
			MainWindow mainWindow = new MainWindow
															{
																DataContext = this
															};
			mainWindow.Show();
		} // OnStartup

		// ----------------------------------------------------------------------
		protected override void OnExit( ExitEventArgs e )
		{
			base.OnExit( e );

			if ( mediaPlayer != null )
			{
				mediaPlayer.Dispose();
			}
			if ( listBoxBinding != null )
			{
				listBoxBinding.Dispose();
			}
			if ( gridViewBinding != null )
			{
				gridViewBinding.Dispose();
			}
			if ( customerAdmin != null )
			{
				customerAdmin.Dispose();
			}
			if ( assemblyBrowser != null )
			{
				assemblyBrowser.Dispose();
			}
			if ( orderBrowser != null )
			{
				orderBrowser.Dispose();
			}
		} // OnExit

		// ----------------------------------------------------------------------
		// members
		private MediaPlayerModel mediaPlayer;
		private ListBoxBindingModel listBoxBinding;
		private GridViewBindingModel gridViewBinding;
		private SelectionModel selection;
		private CustomerAdminModel customerAdmin;
		private AssemblyBrowserModel assemblyBrowser;
		private OrderBrowserModel orderBrowser;

	} // class App

} // namespace Itenso.Community.XamlPatterns.Program
// -- EOF -------------------------------------------------------------------

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.

License

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


Written By
Software Developer (Senior)
Switzerland Switzerland
👨 Senior .NET Software Engineer

🚀 My Open Source Projects
- Time Period Library 👉 GitHub
- Payroll Engine 👉 GitHub

Feedback and contributions are welcome.



Comments and Discussions