Click here to Skip to main content
15,881,882 members
Articles / Desktop Programming / WPF

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

Rate me:
Please Sign up or sign in to vote.
4.80/5 (11 votes)
20 Feb 2012CPOL10 min read 75.2K   4.8K   54  
This article describes the project setup of building a WPF sample application with Self-Tracking Entity Generator for WPF/Silverlight.
//-----------------------------------------------------------------------
// <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>
//-----------------------------------------------------------------------

namespace System.Windows.Controls
{
    /// <summary>
    /// The source of a ValidationSummaryItem, indicating the PropertyName and/or Control.
    /// </summary>
    public class ValidationSummaryItemSource
    {
        /// <summary>
        /// Initializes a new instance of the ValidationSummaryItemSource class.
        /// </summary>
        /// <param name="propertyName">The name of the property associated with this error.</param>
        public ValidationSummaryItemSource(string propertyName) : this(propertyName, null)
        { }

        /// <summary>
        /// Initializes a new instance of the ValidationSummaryItemSource class.
        /// </summary>
        /// <param name="propertyName">The name of the property associated with this error.</param>
        /// <param name="control">The control associated with this error.</param>
        public ValidationSummaryItemSource(string propertyName, Control control)
        {
            this.PropertyName = propertyName;
            this.Control = control;
        }

        /// <summary>
        /// Gets the PropertyName.
        /// </summary>
        public string PropertyName
        {
            get;
            private set;
        }

        /// <summary>
        /// Gets the Control.
        /// </summary>
        public Control Control
        {
            get;
            private set;
        }

        /// <summary>
        /// Implements the equality check against the PropertyName and Control.
        /// </summary>
        /// <param name="obj">The ValidationSummaryItem being compared.</param>
        /// <returns>A value indicating whether the two references are equal in value.</returns>
        public override bool Equals(object obj)
        {
            ValidationSummaryItemSource other = obj as ValidationSummaryItemSource;
            if (other == null)
            {
                return false;
            }
            return this.PropertyName == other.PropertyName && this.Control == other.Control;
        }

        /// <summary>
        /// Returns a HashCode based on the PropertyName and Control Name
        /// </summary>
        /// <returns>The hash value of the ValidationSummaryItemSource.</returns>
        public override int GetHashCode()
        {
            string sourceString = this.PropertyName + "." + this.Control.Name;
            return sourceString.GetHashCode();
        }
    }
}

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 (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

Comments and Discussions