Table of Contents

Class MaskedTextBox

Namespace
Avalonia.Controls
Assembly
Avalonia.Controls.dll
public class MaskedTextBox : TextBox, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue
Inheritance
MaskedTextBox
Implements
Inherited Members
Extension Methods

Constructors

MaskedTextBox()

public MaskedTextBox()

MaskedTextBox(MaskedTextProvider)

Constructs the MaskedTextBox with the specified MaskedTextProvider object.

public MaskedTextBox(MaskedTextProvider maskedTextProvider)

Parameters

maskedTextProvider MaskedTextProvider

Fields

AsciiOnlyProperty

public static readonly StyledProperty<bool> AsciiOnlyProperty

Field Value

StyledProperty<bool>

CultureProperty

public static readonly StyledProperty<CultureInfo?> CultureProperty

Field Value

StyledProperty<CultureInfo>

HidePromptOnLeaveProperty

public static readonly StyledProperty<bool> HidePromptOnLeaveProperty

Field Value

StyledProperty<bool>

MaskCompletedProperty

public static readonly DirectProperty<MaskedTextBox, bool?> MaskCompletedProperty

Field Value

DirectProperty<MaskedTextBox, bool?>

MaskFullProperty

public static readonly DirectProperty<MaskedTextBox, bool?> MaskFullProperty

Field Value

DirectProperty<MaskedTextBox, bool?>

MaskProperty

public static readonly StyledProperty<string?> MaskProperty

Field Value

StyledProperty<string>

PromptCharProperty

public static readonly StyledProperty<char> PromptCharProperty

Field Value

StyledProperty<char>

ResetOnPromptProperty

public static readonly StyledProperty<bool> ResetOnPromptProperty

Field Value

StyledProperty<bool>

ResetOnSpaceProperty

public static readonly StyledProperty<bool> ResetOnSpaceProperty

Field Value

StyledProperty<bool>

Properties

AsciiOnly

Gets or sets a value indicating if the masked text box is restricted to accept only ASCII characters. Default value is false.

public bool AsciiOnly { get; set; }

Property Value

bool

Culture

Gets or sets the culture information associated with the masked text box.

public CultureInfo? Culture { get; set; }

Property Value

CultureInfo

HidePromptOnLeave

Gets or sets a value indicating if the prompt character is hidden when the masked text box loses focus.

public bool HidePromptOnLeave { get; set; }

Property Value

bool

Mask

Gets or sets the mask to apply to the TextBox.

public string? Mask { get; set; }

Property Value

string

MaskCompleted

Specifies whether the test string required input positions, as specified by the mask, have all been assigned.

public bool? MaskCompleted { get; }

Property Value

bool?

MaskFull

Specifies whether all inputs (required and optional) have been provided into the mask successfully.

public bool? MaskFull { get; }

Property Value

bool?

MaskProvider

Gets the MaskTextProvider for the specified Mask.

public MaskedTextProvider? MaskProvider { get; }

Property Value

MaskedTextProvider

PromptChar

Gets or sets the character used to represent the absence of user input in MaskedTextBox.

public char PromptChar { get; set; }

Property Value

char

ResetOnPrompt

Gets or sets a value indicating if selected characters should be reset when the prompt character is pressed.

public bool ResetOnPrompt { get; set; }

Property Value

bool

ResetOnSpace

Gets or sets a value indicating if selected characters should be reset when the space character is pressed.

public bool ResetOnSpace { get; set; }

Property Value

bool

StyleKeyOverride

Gets the type by which the element is styled.

protected override Type StyleKeyOverride { get; }

Property Value

Type

Remarks

Usually controls are styled by their own type, but there are instances where you want an element to be styled by its base type, e.g. creating SpecialButton that derives from Button and adds extra functionality but is still styled as a regular Button. Override this property to change the style for a control class, returning the type that you wish the elements to be styled as.

Methods

CoerceText(string?)

Coerces the current text.

protected override string? CoerceText(string? text)

Parameters

text string

Returns

string

A coerced text.

Remarks

This method also manages the internal undo/redo state whenever the text changes: if overridden, ensure that the base is called or undo/redo won't work correctly.

OnGotFocus(GotFocusEventArgs)

Called before the GotFocus event occurs.

protected override void OnGotFocus(GotFocusEventArgs e)

Parameters

e GotFocusEventArgs

The event args.

OnKeyDown(KeyEventArgs)

Called before the KeyDown event occurs.

protected override void OnKeyDown(KeyEventArgs e)

Parameters

e KeyEventArgs

The event args.

OnLostFocus(RoutedEventArgs)

Called before the LostFocus event occurs.

protected override void OnLostFocus(RoutedEventArgs e)

Parameters

e RoutedEventArgs

The event args.

OnPropertyChanged(AvaloniaPropertyChangedEventArgs)

Called when a avalonia property changes on the object.

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)

Parameters

change AvaloniaPropertyChangedEventArgs

The property change details.

OnTextInput(TextInputEventArgs)

Called before the TextInput event occurs.

protected override void OnTextInput(TextInputEventArgs e)

Parameters

e TextInputEventArgs

The event args.