How To Hide The Prompt Character In .NET MAUI Maskedentry Sfmaskedentry
masked-entry
masked-entry-prompt
maskedinput
maui-masked-entry
synfcusion-masked-entry
The HidePromptOnLeave property provides built-in support for hiding prompt characters when the control loses focus.
To hide or display prompt characters after editing, set the HidePromptOnLeave property:
- When
HidePromptOnLeave = true, prompt characters are hidden when the control loses focus, resulting in a cleaner display. - When
HidePromptOnLeave = false, prompt characters remain visible even after the control loses focus.
This behavior helps improve readability by displaying only the entered values while still allowing users to see prompt characters during editing.
Benefits of Setting PromptChar to Space
- Removes visible placeholder characters.
- Creates a cleaner input field.
- Improves readability.
- Provides a more modern and minimal UI experience.
- Reduces distractions during data entry.
Example Scenario
Consider a date field with the following mask:
MainPage.xaml
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:editors="clr-namespace:Syncfusion.Maui.Inputs;assembly=Syncfusion.Maui.Inputs"
Title="How to hide prompt character in .NET MAUI SfMaskedEntry"
x:Class="MaskedEntrySample.MainPage">
<VerticalStackLayout WidthRequest="250">
<editors:SfMaskedEntry x:Name="maskedEntry"
Placeholder="Enter here"
MaskType="Simple"
Mask="00/00/00"
PromptChar="#"
HidePromptOnLeave="True">
</editors:SfMaskedEntry>
</VerticalStackLayout>
</ContentPage>