Fernando Cerqueira Web Site
Consultor,Arquiteto de Aplicações,Especialista Microsoft .NET
Sunday, February 05, 2012
MaskedEdit Demonstration

MaskedEdit is an Silverlight control to restrict the kind of text that can be entered. This control inherits directly from Textbox control.

Description

MaskedEdit applies a "mask" to the input that permits only certain types of characters/text to be entered. The supported data formats are: Number, Text, Any , Custom, Number and custom, Text and Custom. MaskedEdit uses the culture settings specified in the CultureName property. If none is specified the culture setting will be the same as the current Silverlight thread.

Dependency Properties

Mask: Define the input mask of text. This property is Required.

List of characters for valid input:

  • 9 = only numeric
  • A = only letter
  • C = only Custom - match with property FilterText
  • Z = Numeric + Custom
  • # = Letter + Custom
  • X = any digit

List of valid special characters:

  • \ = Escape character

List of valid modifier Mask:

  • @ = Modifier indicator (valid only at the beginning of the mask)
  • U = Transforms the input to uppercase
  • L = Transforms the input to lowercase

List of valid Pre-Defined Mask:

  • RightNumber([$S]NNN.DDD[$S or S%]) = Number input mask aligned to the right.
    • [$S] = (Optional) Currency Symbol and/or Signal
    • NNN.DDD = (Required) Part of the integer number positions + . + Part of the decimal number positions
    • [S%] = (Optional) Signal and/or Percent symbol.

  • LeftNumber([$S]NNN.DDD[$S or S%]) = Number input mask aligned to the left.
    • [$S] = (Optional) Currency Symbol and/or Signal
    • NNN.DDD = (Required) Part of the integer number positions + . + Part of the decimal number positions
    • [S%] = (Optional) Signal and/or Percent symbol.

  • R{?}([U|L]NNN) = Repeater Mask ? NNN times.
    • ? = any char of list valid input.
    • [U|L] = Optional transforms the input to uppercase or lowercase.

  • ShortDate = input mask to format Date : 99/99/99.

  • LongDate = input mask to format Date : 99/99/9999.

  • ShortTime = input mask to format Date : 99:99.

  • LongTime = input mask to format Date : 99:99:99.

  • ShortTimeAMPM = input mask to format Date : 99:99 [AM/PM].

  • LongTimeAMPM = input mask to format Date : 99:99:99 [AM/PM].

Remarks 1 : Characters [AM/PM] S / : . , % $ will be replaced by the equivalent of the language/culture defined by the property CultureInput.

Remarks 2 : The symbol Signal S is captured in any position that is the cursor.

Remarks 3 : The symbol [AM/PM] is captured in any position that is the cursor and changed with fist letter of Symbol.

PromptCharacter: Prompt character for unspecified mask characters. Default value is _ .

CultureInput: Name of culture to use . Default value is thread culture Current.

CultureLoad: Name of culture to load data . Default value is thread culture Current.

FilterText: Valid characters for mask type "C","Z","#" (case-sensitive).Default value is empty.

NegativeBackground: Brush Background when the TextBox gets value negative. Default value is null.

NegativeForeground: Brush Foreground when the TextBox gets value negative. Default value is null.

UnMaskPreserveDisplayCulture: If true, preserve placeholders and Symbols of culture input. False translate for CultureLoad property. Default value is false.

TextUnMasked: Content text widhout masked. Read only.

UnMaskedAtLostfocus: If true, unmasked content text at lostfocus and replace placeholders and Symbols to CutureLoad property or preserve culture format if UnMaskPreserveDisplayCulture property is true.

FixedCursorRightPosition: If true, Fixed Cursor at last valid position. Default value is false. Remarks: This property only valid for mask = RightNumber.When mask is LeftNumber (behavior align left), this property is ignored.

ReplaceEmptyText: Exchange with the PromptCharacter and mask = 'X' the content of this property.Default value Empty. Accepts only one character.

ReplaceEmptyNumeric: Exchange with the PromptCharacter and mask = '9' the content of this property.Default value Empty. Accepts only one character.

Methods

Realod (): Reload all properties and initial data.The last data input is lost.

LoadText (Object Value): Convert data input to mask input formated.

Paramets:

  • Value = Data to covert.The Culture used is same CultureLoad property.

LoadText (Object Value,CultureInfo Culture): Convert data input to mask input formated with Culture (Overrider CultureLoad property).

Paramets:

  • Value = Data to covert.
  • Culture = CultureInfo to overrider.