Click here to Skip to main content
15,896,606 members
Articles / Web Development / HTML

A WPF Template solution using MVVM and Castle Windsor

Rate me:
Please Sign up or sign in to vote.
4.78/5 (11 votes)
18 Nov 2013CPOL5 min read 34.9K   1.2K   19  
A WPF application base solution using Castle Windsor and commonly used utilities.
using System;
using System.Windows;
using System.Windows.Controls;
using Interfaces;

namespace Map
{
    /// <summary>
    /// Interaction logic for MapView.xaml
    /// </summary>
    public partial class MapView : UserControl, IMapView
    {
        private IMapViewModel _theMapViewModel;
        private readonly IViewFactory _viewFactory;

        /// <summary>
        /// The View Model.
        /// (Automatically Injected by the Castle Windsor Framework)
        /// </summary>
        public IMapViewModel TheMapViewModel
        {
            get
            {
                return _theMapViewModel;
            }
            set
            {
                _theMapViewModel = value;
                DataContext = _theMapViewModel.TheModel;
            }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="MapView"/> class.
        /// </summary>
        public MapView(IViewFactory viewFactory)
        {
            InitializeComponent();
            _viewFactory = viewFactory;
        }

        #region IView Members

        /// <summary>
        /// Return the View Content.
        /// </summary>
        /// <returns></returns>
        public object GetContent()
        {
            return this.Content;
        }

        #endregion


        #region IMapView Members


        public void ShowView<TView>() where TView : IView
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            throw new NotImplementedException();
        }

        #endregion


        #region Handlers

        private void buttonHelp_Click(object sender, RoutedEventArgs e)
        {
            TheMapViewModel.HandleHelp(e.Source);
        }

        #endregion
    }
}

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) Scodix
Israel Israel
Project Manager and Application Developer, in a wide variety of business applications. Particularly interested in client/server and Graphical User Interface design using Visual C#.

Specialties: 13 Y'rs in C#, 10 Y'rs experience in C++ Highly experienced in wide technologies, IT projects, military projects etc'.

Comments and Discussions