Click here to Skip to main content
15,884,099 members
Articles / Desktop Programming / WPF

Catel - Part 3 of n: The MVVM Framework

Rate me:
Please Sign up or sign in to vote.
4.58/5 (20 votes)
28 Jan 2011CPOL37 min read 125.8K   2K   42  
This article explains the MVVM framework that ships with Catel.
using System.Windows;
using Catel.Articles._03___MVVM.UI.ViewModels;
using Catel.MVVM.UI;
using Catel.Windows;

namespace Catel.Articles._03___MVVM.Examples.ControlToViewModelWithWindow
{
    /// <summary>
    /// Interaction logic for WindowWithViewModelMappings.xaml
    /// </summary>
    public partial class WindowWithViewModelMappings : DataWindow<PersonViewModel>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="WindowWithViewModelMappings"/> class.
        /// </summary>
        public WindowWithViewModelMappings()
        {
            // Initialize component
            InitializeComponent();
        }

        /// <summary>
        /// Gets or sets the first name.
        /// </summary>
        /// <value>The first name.</value>
        [ControlToViewModel]
        public string FirstName
        {
            get { return (string)GetValue(FirstNameProperty); }
            set { SetValue(FirstNameProperty, value); }
        }

        // Using a DependencyProperty as the backing store for FirstName.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty FirstNameProperty =
            DependencyProperty.Register("FirstName", typeof(string), typeof(WindowWithViewModelMappings), new UIPropertyMetadata(string.Empty));
    }
}

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
Netherlands Netherlands
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions