Click here to Skip to main content
12,396,461 members (36,604 online)
Click here to Skip to main content

Tagged as

Stats

43.8K views
1.1K downloads
41 bookmarked
Posted

Model View Presenter with WPF and Unity Container

, 1 Jan 2009 CPOL
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;

namespace CustomerInfoObserver
{
    public class CustomerPresenter : BasePresenter<ICustomerView>
    {
        private CustomerModel _customerModel;

        public CustomerPresenter(CustomerDataSource someDataSourceService) { }

        public override void OnViewInitialized()
        {
            _customerModel = new CustomerModel() { CustomerName = "xyz" };
            View.SetCustomerModelAsDataContext(_customerModel); 
        }
        
        public void OnAddCustomer(string customerName)
        {
            //---Business logic
            _customerModel.CustomerName = "Updated Name - " + customerName;
        }

        public override void OnViewFinalize() {}
    }
}

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
Web02 | 2.8.160721.1 | Last Updated 1 Jan 2009
Article Copyright 2009 by suraj mehare
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid