Click here to Skip to main content
11,583,865 members (62,980 online)
Click here to Skip to main content
Add your own
alternative version

Model View Presenter with WPF and Unity Container

, 1 Jan 2009 CPOL 40.3K 1K 39
This article demonstrates using a model view presenter (MVP) pattern in a sample program.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace CustomerInfoObserver
{
    /// <summary>
    /// Interaction logic for CustomerView.xaml
    /// </summary>
    public partial class CustomerView
        : BaseView<ICustomerView, CustomerPresenter>, ICustomerView
    {
        public CustomerView()
        {
            InitializeComponent();

            Presenter.OnViewInitialized();
        }

        public void SetCustomerModelAsDataContext(CustomerModel customerModel)
        {
            this.DataContext = customerModel;
        }

        private void btnAddCustomer_Click(object sender, RoutedEventArgs e)
        {
            Presenter.OnAddCustomer(txtCustomerName.Text);
        }

        
    }
}

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)

Share

About the Author

suraj mehare
India India
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150603.1 | Last Updated 1 Jan 2009
Article Copyright 2009 by suraj mehare
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid