Click here to Skip to main content
15,892,674 members
Articles / Desktop Programming / WPF

Master page in WPF?

Rate me:
Please Sign up or sign in to vote.
4.36/5 (4 votes)
4 Nov 2013CPOL3 min read 27.4K   1K   9  
How to implement the master page pattern in WPF?
using System.Windows;

namespace MasterPage.Model
{
    /// <summary>
    /// Sample model for the application.
    /// </summary>
    public sealed class MainModel : DependencyObject
    {
        /// <summary>
        /// Main model singleton.
        /// </summary>
        private static readonly MainModel _TheMainModel = new MainModel();

        /// <summary>
        /// Private constructor.
        /// </summary>
        private MainModel()
        {
        }

        /// <summary>
        /// Singleton accessor.
        /// </summary>
        public static MainModel TheMainModel
        {
            get
            {
                return _TheMainModel; 
            }
        }

        /// <summary>
        /// Accessor for dependency property prop1.
        /// </summary>
        public string prop1
        {
            get { return (string)GetValue(prop1Property); }
            set { SetValue(prop1Property, value); }
        }

        /// <summary>
        /// Accessor for dependency property prop2.
        /// </summary>
        public string prop2
        {
            get { return (string)GetValue(prop2Property); }
            set { SetValue(prop2Property, value); }
        }

        /// <summary>
        /// Accessor for dependency property prop3.
        /// </summary>
        public string prop3
        {
            get { return (string)GetValue(prop3Property); }
            set { SetValue(prop3Property, value); }
        }

        /// <summary>
        /// Accessor for dependency property prop4.
        /// </summary>
        public string prop4
        {
            get { return (string)GetValue(prop4Property); }
            set { SetValue(prop4Property, value); }
        }

        /// <summary>
        /// Dependency property prop1.
        /// </summary>
        public static readonly DependencyProperty prop1Property = DependencyProperty.Register("prop1", typeof(string), typeof(MainModel));
        
        /// <summary>
        /// Dependency property prop2.
        /// </summary>
        public static readonly DependencyProperty prop2Property = DependencyProperty.Register("prop2", typeof(string), typeof(MainModel));

        /// <summary>
        /// Dependency property prop3.
        /// </summary>
        public static readonly DependencyProperty prop3Property = DependencyProperty.Register("prop3", typeof(string), typeof(MainModel));

        /// <summary>
        /// Dependency property prop4.
        /// </summary>
        public static readonly DependencyProperty prop4Property = DependencyProperty.Register("prop4", typeof(string), typeof(MainModel));
    }
}

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)
France France
Being a software developer since 1994, I have worked in the US (DC area), and in France (Paris area), on various types of projects (device drivers, Imaging, Financial apps and database-driven web sites).

My favourite technical interests are C++, C#, .net, WPF, image analysis, GPUs, GPGPU, AI, and compilers.

See : http://www.BareImagesToolbox.com

Comments and Discussions