MaskedTextBox Class
Represents a TextBox
that restricts input based on a specified mask.
public class MaskedTextBox : TextBox, DUCE.IResource, IAnimatable, IFrameworkInputElement, IInputElement, ISupportInitialize, IHaveResources, IQueryAmbient, IAddChild, ITextBoxViewHost
- Inheritance:
- Object DispatcherObject DependencyObject Visual UIElement FrameworkElement Control TextBoxBase TextBox Object
Constructors
MaskedTextBox()
Initializes an instance of the MaskedTextBox
class.
public MaskedTextBox()
Properties
IsCaseAutoCorrected
Gets or sets whether characters entered will have their case auto-corrected to match the defined mask.
public bool IsCaseAutoCorrected { get; set; }
Property Value
- Boolean:
true
if characters entered will have their case auto-corrected to match the defined mask; otherwise,false
. The default value isfalse
.
Remarks
When this property is set to true
, then the IsCaseSensitive property is ignored.
IsCaseSensitive
Gets or sets whether the mask is case sensitive.
public bool IsCaseSensitive { get; set; }
Property Value
- Boolean:
true
if the mask is case sensitive; otherwise,false
. The default value isfalse
.
Remarks
When the IsCaseAutoCorrected property is set to true
, this property is ignored.
IsMatched
Gets whether the input text successfully matches the pattern.
public bool IsMatched { get; }
Property Value
- Boolean:
true
if the input text successfully matches the pattern; otherwise,false
.
Mask
Gets or sets the text that designates the input mask.
public string Mask { get; set; }
Property Value
- String:
The text that designates the input mask. The default value is null.
MaskKind
Gets or sets the kind of input mask.
public MaskKind MaskKind { get; set; }
Property Value
- MaskKind:
The kind of input mask. The default value is
Regex
.
MatchedText
Gets or sets the matched text, which is generally the same as the Text
property but without any prompt characters included.
public string MatchedText { get; set; }
Property Value
- String:
The matched text.
Remarks
Any bindings to MaskedTextBox should bind to this property instead of Text
, so that prompt characters aren't included in the result.
PromptChar
Gets or sets the character used to indicate required input.
public char PromptChar { get; set; }
Property Value
- Char:
The character used to indicate required input. The default value is
\u2022
.
PromptVisibility
Gets or sets the visibility of mask prompts.
public MaskPromptVisibility PromptVisibility { get; set; }
Property Value
- MaskPromptVisibility:
A MaskPromptVisibility that indicates the visibility of mask prompts. The default value is
FocusedOnly
.
Methods
OnGotFocus(RoutedEventArgs)
Occurs when the control gains focus.
protected override void OnGotFocus(RoutedEventArgs e)
Parameter | Type | Description |
---|---|---|
e | RoutedEventArgs | The RoutedEventArgs that contains the event data. |
OnLostFocus(RoutedEventArgs)
Occurs when the control loses focus.
protected override void OnLostFocus(RoutedEventArgs e)
Parameter | Type | Description |
---|---|---|
e | RoutedEventArgs | The RoutedEventArgs that contains the event data. |
OnMouseDown(MouseButtonEventArgs)
Occurs when a pointer button is down.
protected override void OnMouseDown(MouseButtonEventArgs e)
Parameter | Type | Description |
---|---|---|
e | MouseButtonEventArgs | The MouseButtonEventArgs that contains the event data. |
Events
IsMatchedChanged
Occurs after the IsMatched property value changes.
Fields
IsCaseAutoCorrectedProperty
Identifies the IsCaseAutoCorrected dependency property. This field is read-only.
public static readonly DependencyProperty IsCaseAutoCorrectedProperty
IsCaseSensitiveProperty
Identifies the IsCaseSensitive dependency property. This field is read-only.
public static readonly DependencyProperty IsCaseSensitiveProperty
IsMatchedProperty
Identifies the IsMatched dependency property. This field is read-only.
public static readonly DependencyProperty IsMatchedProperty
MaskKindProperty
Identifies the MaskKind dependency property. This field is read-only.
public static readonly DependencyProperty MaskKindProperty
MaskProperty
Identifies the Mask dependency property. This field is read-only.
public static readonly DependencyProperty MaskProperty
MatchedTextProperty
Identifies the MatchedText dependency property. This field is read-only.
public static readonly DependencyProperty MatchedTextProperty
PromptCharProperty
Identifies the PromptChar dependency property. This field is read-only.
public static readonly DependencyProperty PromptCharProperty
PromptVisibilityProperty
Identifies the PromptVisibility dependency property. This field is read-only.
public static readonly DependencyProperty PromptVisibilityProperty
Inherited Members
- Object.ToString()
- Object.Equals(Object)
- Object.Equals(Object, Object)
- Object.ReferenceEquals(Object, Object)
- Object.GetHashCode()
- Object.GetType()
- Object.MemberwiseClone()