Click here to Skip to main content
15,896,063 members
Articles / Web Development / ASP.NET

Take MVC to the Next Level in .NET

Rate me:
Please Sign up or sign in to vote.
4.62/5 (11 votes)
30 Apr 2013GPL315 min read 73.2K   858   75  
How to quickly build reusable and flexible WPF, Silverlight, or ASP.NET applications with the powerful Xomega Framework using the best MVVM principles.
using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.Windows;
using System.Windows.Input;
using MyProject4.Client.Objects;
using MyProject4.Services;
using Xomega.Framework;

namespace MyProject4.Client.WPF
{
    public partial class StoreReadListForm : Window
    {
        private StoreCriteria criteria;
        private DataObjectList<StoreRowObject> list;

        public StoreReadListForm()
        {
            InitializeComponent();
        }

        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            criteria = new StoreCriteria();
            pnlCriteria.DataContext = criteria;
            list = new DataObjectList<StoreRowObject>();
            list.Editable = false;
            gridResults.ItemsSource = list;
            PostInitialize();
        }

        partial void PostInitialize();

        public void Refresh()
        {
            btnSearch_Click(null, null);
        }

        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            criteria.Validate(true);
            ErrorList valErr = criteria.GetValidationErrors();
            if (valErr.HasErrors())
            {
                Errors.Show(valErr);
                return;
            }
            Store_ReadListInput input = new Store_ReadListInput();
            criteria.ToDataContract(input);

            ChannelFactory<IStoreService> factory = new ChannelFactory<IStoreService>("IStoreService");
            IStoreService svc = factory.CreateChannel();
            List<Store_ReadListOutput> output = svc.ReadList(input);
            list.FromDataContract(output);
            factory.Close();
        }
        
        private void btnReset_Click(object sender, RoutedEventArgs e)
        {
            list.Clear();
        }

        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }
    }
}

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 GNU General Public License (GPLv3)


Written By
Architect Xomega.Net
United States United States
Xomega Team is striving to increase productivity and development quality by utilizing Model Driven Development coupled with Code Generation and the best design practices for application development.
We provide MDD tools, code generators and frameworks for Visual Studio and .Net development.
Visit us at http://www.xomega.net
This is a Organisation

1 members

Comments and Discussions