Click here to Skip to main content
12,502,009 members (53,233 online)
Click here to Skip to main content

Stats

44.6K views
4.3K downloads
55 bookmarked
Posted

Building WPF Applications with Self-Tracking Entity Generator - Project Setup

, 20 Feb 2012 CPOL
This article describes the project setup of building a WPF sample application with Self-Tracking Entity Generator for WPF/Silverlight.
SchoolSample
Local.testsettings
SchoolSample.vsmdi
TraceAndTestImpact.testsettings
Assemblies
GalaSoft.MvvmLight.Extras.WPF4.dll
GalaSoft.MvvmLight.WPF4.dll
Moq.dll
System.Windows.Interactivity.dll
WPFToolkit.Extended.dll
ComponentModel.Composition.Initialization.Desktop
Microsoft
ComponentModel
Composition
Hosting
Internal
Properties
System
ComponentModel
Composition
Hosting
System.Windows.Controls.Data.Input
Common
Properties
themes
Validation
Database
SchoolSample
SchoolSample.csproj.user
Asset
Control
Properties
View
SchoolSample.Common
Model
Properties
Resource
SchoolSample.Data
EntityModel
Properties
Validation
SchoolSample.Data.Wcf
EntityModel
SchoolModel.edmx
Properties
Validation
SchoolSample.Model
Properties
SchoolSample.ViewModel
Properties
SchoolSample.Wcf
SchoolSample.Wcf.csproj.user
Properties
Service
SchoolService.svc
SchoolSample.WCFService
SchoolSample.WCFService.csproj.user
Properties
Service References
SchoolService
configuration.svcinfo
configuration91.svcinfo
Reference.svcmap
SchoolService.disco
SchoolService.wsdl
Test.SchoolSample.Model
Properties
Test References
SchoolSample.Model.accessor
Test.SchoolSample.ViewModel
Properties
Test References
SchoolSample.ViewModel.accessor
Local.testsettings
SchoolSample.vsmdi
TraceAndTestImpact.testsettings
GalaSoft.MvvmLight.Extras.WPF4.dll
GalaSoft.MvvmLight.WPF4.dll
Moq.dll
System.Windows.Interactivity.dll
WPFToolkit.Extended.dll
SchoolSample.csproj.user
SchoolModel.edmx
SchoolSample.Wcf.csproj.user
SchoolService.svc
SchoolSample.WCFService.csproj.user
configuration.svcinfo
configuration91.svcinfo
Reference.svcmap
SchoolService.disco
SchoolService.wsdl
SchoolSample.Model.accessor
SchoolSample.ViewModel.accessor
Local.testsettings
SchoolSample.vsmdi
TraceAndTestImpact.testsettings
GalaSoft.MvvmLight.Extras.WPF4.dll
GalaSoft.MvvmLight.WPF4.dll
Moq.dll
System.Windows.Interactivity.dll
WPFToolkit.Extended.dll
SchoolSample.csproj.user
SchoolModel.edmx
SchoolSample.Wcf.csproj.user
SchoolService.svc
SchoolSample.WCFService.csproj.user
configuration.svcinfo
configuration91.svcinfo
Reference.svcmap
SchoolService.disco
SchoolService.wsdl
SchoolSample.Model.accessor
SchoolSample.ViewModel.accessor
//-----------------------------------------------------------------------
// <copyright company="Microsoft">
//      (c) Copyright Microsoft Corporation.
//      This source is subject to the Microsoft Public License (Ms-PL).
//      Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
//      All other rights reserved.
// </copyright>
//-----------------------------------------------------------------------

using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Globalization;
using resources = System.Windows.Controls.Data.Input.Resources;

namespace System.Windows.Controls
{
    /// <summary>
    /// Represents an individual validation error.
    /// </summary>
    /// <QualityBand>Preview</QualityBand>
    public class ValidationSummaryItem : INotifyPropertyChanged
    {
        internal const string PROPERTYNAME_ITEMTYPE = "ItemType";
        private object _context;
        private ValidationSummaryItemType _itemType;
        private string _message;
        private string _messageHeader;

        /// <summary>
        /// Initializes a new instance of the ValidationSummaryItem class.
        /// </summary>
        public ValidationSummaryItem() : this(null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the ValidationSummaryItem class.
        /// </summary>
        /// <param name="message">The error message.</param>
        public ValidationSummaryItem(string message) : this(message, null, ValidationSummaryItemType.ObjectError, null, null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the ValidationSummaryItem class.
        /// </summary>
        /// <param name="message">The error message.</param>
        /// <param name="messageHeader">The header/prefix of the item, such as the property name.</param>
        /// <param name="itemType">The type of error, such as Property or Entity level.</param>
        /// <param name="source">The source of the error message, including the originating control and/or property name.</param>
        /// <param name="context">Context from which the error occurred.  This general property can be used as a container to keep track of the entity, for instance.</param>
        public ValidationSummaryItem(string message, string messageHeader, ValidationSummaryItemType itemType, ValidationSummaryItemSource source, object context)
        {
            this.MessageHeader = messageHeader;
            this.Message = message;
            this.ItemType = itemType;
            this.Context = context;
            this.Sources = new ObservableCollection<ValidationSummaryItemSource>();
            if (source != null)
            {
                this.Sources.Add(source);
            }
        }

        /// <summary>
        /// Gets or sets the object that is the context in which the error occurred.
        /// </summary>
        public object Context
        {
            get
            {
                return this._context;
            }

            set
            {
                if (this._context != value)
                {
                    this._context = value;
                    this.NotifyPropertyChanged("Context");
                }
            }
        }

        /// <summary>
        /// Gets a value that specifies whether the error originated from an object or a property.
        /// </summary>
        public ValidationSummaryItemType ItemType
        {
            get
            {
                return this._itemType;
            }

            set
            {
                if (this._itemType != value)
                {
                    this._itemType = value;
                    // Uses const due to the special case where ItemType changes affect filtering.
                    this.NotifyPropertyChanged(PROPERTYNAME_ITEMTYPE);
                }
            }
        }

        /// <summary>
        /// Gets or sets the text of the error message.
        /// </summary>
        public string Message
        {
            get
            {
                return this._message;
            }

            set
            {
                if (this._message != value)
                {
                    this._message = value;
                    this.NotifyPropertyChanged("Message");
                }
            }
        }

        /// <summary>
        /// Gets the reference to the input control that resulted in this error
        /// </summary>
        public string MessageHeader
        {
            get
            {
                return this._messageHeader;
            }

            set
            {
                if (this._messageHeader != value)
                {
                    this._messageHeader = value;
                    this.NotifyPropertyChanged("MessageHeader");
                }
            }
        }

        /// <summary>
        /// Gets the sources of the error.
        /// </summary>
        public ObservableCollection<ValidationSummaryItemSource> Sources
        {
            get;
            private set;
        }

        /// <summary>
        /// The string representation of the error.
        /// </summary>
        /// <returns>The string representation of the ValidationSummaryItem.</returns>
        public override string ToString()
        {
            return String.Format(CultureInfo.InvariantCulture, resources.ValidationSummaryItem, this.MessageHeader, this.Message);
        }

        private void NotifyPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = this.PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #region INotifyPropertyChanged Members

        /// <summary>
        /// This event is raised when any of the properties on the object change
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        #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)

Share

About the Author

Weidong Shen
Software Developer (Senior)
United States United States
Weidong has been an information system professional since 1990. He has a Master's degree in Computer Science, and is currently a MCSD .NET

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160919.1 | Last Updated 20 Feb 2012
Article Copyright 2011 by Weidong Shen
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid