Click here to Skip to main content
15,896,912 members
Articles / Desktop Programming / WPF

Validizor - A Validation Control for WPF

Rate me:
Please Sign up or sign in to vote.
4.66/5 (16 votes)
17 Oct 2007CPOL7 min read 94.7K   4.3K   58  
A WPF validation control for validating your data objects.
//---------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation.  All rights reserved.
//
//---------------------------------------------------------------------------
using System;
using System.Windows;

namespace Microsoft.Samples.KMoore.WPFSamples.DateControls
{
    /// <summary>
    /// The InvalidEntry event args, occurs when the datepicker can't parse user input string correctly
    /// </summary>
    public class InvalidEntryEventArgs : RoutedEventArgs
    {
        /// <summary>
        /// Constructor
        /// </summary>
        public InvalidEntryEventArgs(RoutedEvent id, string entry)
            : base()
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }

            RoutedEvent = id;
            _entry = entry;
        }

        /// <summary>
        /// The input string
        /// </summary>
        public string Entry
        {
            get { return _entry; }
        }

        /// <summary>
        /// This method is used to perform the proper type casting in order to
        /// call the type-safe InvalidEntryEventHandler delegate for the InvalidEntry event.
        /// </summary>
        /// <param name="genericHandler">The handler to invoke.</param>
        /// <param name="genericTarget">The current object along the event's route.</param>
        protected override void InvokeEventHandler(Delegate genericHandler, object genericTarget)
        {
            InvalidEntryEventHandler handler = (InvalidEntryEventHandler)genericHandler;
            handler(genericTarget, this);
        }

        private string _entry;
    }

    /// <summary>
    /// The delegate type for handling the InvalidEntry event
    /// </summary>
    public delegate void InvalidEntryEventHandler(object sender, InvalidEntryEventArgs e);

}

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
United States United States
software engineer

Comments and Discussions