Hiding Prompt Characters in .NET MAUI Masked Entry

21 Jul 20262 minutes to read

Prerequisites

Before using the SfMaskedEntry, ensure the following NuGet package is installed in your .NET MAUI project:

  • Syncfusion.Maui.Inputs

For a step-by-step setup, refer to the Getting Started documentation.

Setting HidePromptOnLeave

The HidePromptOnLeave property of type bool controls whether unfilled prompt positions are displayed when the control does not have focus. The default value is false, which means prompt characters are always shown. When set to true, prompt characters are hidden when the control loses focus and restored when the control regains focus.

The control is considered to have lost focus when the user taps outside the Entry, navigates to another input, or moves focus programmatically via the Unfocused event. To programmatically focus the Entry and restore the prompt, call maskedEntry.Focus().

The following example demonstrates how to hide prompt characters when the Masked Entry control loses focus:

<editors:SfMaskedEntry x:Name="maskedEntry"
                       Placeholder="Enter here"
                       MaskType="Simple"
                       Mask="00/00/0000"
                       PromptChar="#"
                       HidePromptOnLeave="True"/>
SfMaskedEntry maskedEntry = new SfMaskedEntry
{
    Placeholder = "Enter here",
    MaskType = MaskedEntryMaskType.Simple,
    Mask = "00/00/0000",
    PromptChar = '#',
    HidePromptOnLeave = true
};

The following GIF shows the HidePromptOnLeave behavior: prompt characters are visible while the control is focused, and hidden when the control loses focus.

HidePromptOnLeave

See Also