C# Class WPF.JoshSmith.Controls.Validation.RegexValidator

This static class provides attached properties which supply validation of the text in a TextBox, using regular expressions.
Documentation: http://www.codeproject.com/KB/WPF/RegexValidationInWPF.aspx
Datei anzeigen Open project: Warewolf-ESB/Warewolf

Public Properties

Property Type Description
ErrorMessageProperty System.Windows.DependencyProperty
RegexTextProperty System.Windows.DependencyProperty

Public Methods

Method Description
GetErrorMessage ( TextBox textBox ) : string

Returns the error message used when validation fails for the specified TextBox.

GetRegexText ( TextBox textBox ) : string

Returns the regular expression used to validate the specified TextBox.

SetErrorMessage ( TextBox textBox, string value ) : void

Sets the error message used when validation fails for the specified TextBox.

SetRegexText ( TextBox textBox, string value ) : void

Sets the regular expression used to validate the specified TextBox.

Private Methods

Method Description
GetRegexValidationRuleForTextBox ( TextBox textBox ) : RegexValidationRule

Returns a RegexValidationRule to be used for validating the specified TextBox. If the TextBox is not yet initialized, this method returns null.

OnAttachedPropertyChanged ( DependencyObject depObj, System.Windows.DependencyPropertyChangedEventArgs e ) : void

Invoked whenever an attached property of the RegexValidator is modified for a TextBox.

RegexValidator ( ) : System
VerifyRegexValidationRule ( TextBox textBox ) : void

Creates or modifies the RegexValidationRule in the TextBox's Text property binding to use the current values of the attached properties exposed by this class.

Method Details

GetErrorMessage() public static method

Returns the error message used when validation fails for the specified TextBox.
public static GetErrorMessage ( TextBox textBox ) : string
textBox System.Windows.Controls.TextBox The TextBox whose error message is returned.
return string

GetRegexText() public static method

Returns the regular expression used to validate the specified TextBox.
public static GetRegexText ( TextBox textBox ) : string
textBox System.Windows.Controls.TextBox The TextBox whose regular expression is returned.
return string

SetErrorMessage() public static method

Sets the error message used when validation fails for the specified TextBox.
public static SetErrorMessage ( TextBox textBox, string value ) : void
textBox System.Windows.Controls.TextBox The TextBox being validated.
value string The error message.
return void

SetRegexText() public static method

Sets the regular expression used to validate the specified TextBox.
public static SetRegexText ( TextBox textBox, string value ) : void
textBox System.Windows.Controls.TextBox The TextBox being validated.
value string The regular expression.
return void

Property Details

ErrorMessageProperty public_oe static_oe property

Identifies the RegexValidator's ErrorMessage attached property. This field is read-only.
public static DependencyProperty,System.Windows ErrorMessageProperty
return System.Windows.DependencyProperty

RegexTextProperty public_oe static_oe property

Identifies the RegexValidator's RegexText attached property. This field is read-only.
public static DependencyProperty,System.Windows RegexTextProperty
return System.Windows.DependencyProperty