.NET MAUI Documentation

Microsoft Learn

Entry Control

The Entry control in .NET MAUI is used for displaying a single-line text input field.

Basic Usage

You can add an Entry control to your XAML markup like this:

<Entry Text="Placeholder text" />

This will render a simple text input field with "Placeholder text" as its initial content and a visual cue for where the user can type.

Customization

The Entry control offers several properties to customize its appearance and behavior:

Example: A Configured Entry

XAML Example

<Entry
    Placeholder="Enter your email"
    PlaceholderColor="Gray"
    TextColor="DarkBlue"
    Keyboard="Email"
    IsPassword="False"
    BackgroundColor="White"
    BorderColor="LightGray"
    WidthRequest="300"
    Margin="10" />

Handling Input Events

You can respond to user input by handling events such as TextChanged, which fires whenever the text in the entry changes.

XAML with Event Handling

<Entry
    Placeholder="Type something..."
    TextChanged="OnEntryTextChanged" />

<Label x:Name="OutputLabel" />

C# Code-Behind

public partial class MyPage : ContentPage
{
    public MyPage()
    {
        InitializeComponent();
    }

    void OnEntryTextChanged(object sender, TextChangedEventArgs e)
    {
        OutputLabel.Text = $"You typed: {e.NewTextValue}";
    }
}

Platform-Specific Appearance

The appearance of the Entry control can vary slightly across different platforms (iOS, Android, Windows) to adhere to native UI conventions. You can use platform-specific renderers or handlers to further customize its look and feel if needed.