Xamarin.Forms Entry

Single-line text or password input

The Xamarin.Forms Entry is used for single-line text input. The Entry, like the Editor view, supports multiple keyboard types. Additionally, the Entry can be used as a password field.

Display Customization

Setting and Reading Text

The Entry, like other text-presenting views, exposes the Text property. This property can be used to set and read the text presented by the Entry. The following example demonstrates setting the Text property in XAML:

<Entry Text="I am an Entry" />

In C#:

var MyEntry = new Entry { Text = "I am an Entry" };

To read text, access the Text property in C#:

var text = MyEntry.Text;


The width of an Entry can be defined by setting its WidthRequest property. Do not depend on the width of an Entry being defined based on the value of its Text property.

Limiting Input Length

The MaxLength property can be used to limit the input length that's permitted for the Entry. This property should be set to a positive integer:

<Entry ... MaxLength="10" />
var entry = new Entry { ... MaxLength = 10 };

A MaxLength property value of 0 indicates that no input will be allowed, and a value of int.MaxValue, which is the default value for an Entry, indicates that there is no effective limit on the number of characters that may be entered.


The keyboard that is presented when users interact with an Entry can be set programmatically via the Keyboard property.

The options for the keyboard type are:

  • Default – the default keyboard
  • Chat – used for texting & places where emoji are useful
  • Email – used when entering email addresses
  • Numeric – used when entering numbers
  • Telephone – used when entering telephone numbers
  • Url – used for entering file paths and web addresses

There is an example of each keyboard in our Recipes section.

Enabling and Disabling Spell Checking

The IsSpellCheckEnabled property controls whether spell checking is enabled. By default, the property is set to true. As the user enters text, misspellings are indicated.

However, for some text entry scenarios, such as entering a username, spell checking provides a negative experience and so should be disabled by setting the IsSpellCheckEnabled property to false:

<Entry ... IsSpellCheckEnabled="false" />
var entry = new Entry { ... IsSpellCheckEnabled = false };


When the IsSpellCheckEnabled property is set to false, and a custom keyboard isn't being used, the native spell checker will be disabled. However, if a Keyboard has been set that disables spell checking, such as Keyboard.Chat, the IsSpellCheckEnabled property is ignored. Therefore, the property cannot be used to enable spell checking for a Keyboard that explicitly disables it.


Entry can be set to show placeholder text when it is not storing user input. In practice, this is often seen in forms to clarify the content that is appropriate for a given field. Placeholder text color cannot be customized and will be the same regardless of the TextColor setting. If your design calls for a custom placeholder color, you'll need to fall back to a custom renderer. The following will create an Entry with "Username" as the placeholder in XAML:

<Entry Placeholder="Username" />

In C#:

var MyEntry = new Entry { Placeholder = "Username" };

Password Fields

Entry provides the IsPassword property. When IsPassword is true, the contents of the field will be presented as black circles:


<Entry IsPassword="true" />

In C#:

var MyEntry = new Entry { IsPassword = true };

Placeholders may be used with instances of Entry that are configured as password fields:


<Entry IsPassword="true" Placeholder="Password" />

In C#:

var MyEntry = new Entry { IsPassword = true, Placeholder = "Password" };


Entry can be set to use a custom background and text colors via the following bindable properties:

  • TextColor – sets the color of the text.
  • BackgroundColor – sets the color shown behind the text.

Special care is necessary to ensure that colors will be usable on each platform. Because each platform has different defaults for text and background colors, you'll often need to set both if you set one.

Use the following code to set the text color of an entry:


<Entry TextColor="Green" />

In C#:

var entry = new Entry();
entry.TextColor = Color.Green;

Note that the placeholder is not affected by the specified TextColor.

To set the background color in XAML:

<Entry BackgroundColor="#2c3e50" />

In C#:

var entry = new Entry();
entry.BackgroundColor = Color.FromHex("#2c3e50");

Be careful to make sure that the background and text colors you choose are usable on each platform and don't obscure any placeholder text.

Events and Interactivity

Entry exposes two events:

  • TextChanged – raised when the text changes in the entry. Provides the text before and after the change.
  • Completed – raised when the user has ended input by pressing the return key on the keyboard.


The Completed event is used to react to the completion of an interaction with an Entry. Completed is raised when the user ends input with a field by entering the return key on the keyboard. The handler for the event is a generic event handler, taking the sender and EventArgs:

void Entry_Completed (object sender, EventArgs e)
    var text = ((Entry)sender).Text; //cast sender to access the properties of the Entry

The completed event can be subscribed to in XAML:

<Entry Completed="Entry_Completed" />

and C#:

var entry = new Entry ();
entry.Completed += Entry_Completed;


The TextChanged event is used to react to a change in the content of a field.

TextChanged is raised whenever the Text of the Entry changes. The handler for the event takes an instance of TextChangedEventArgs. TextChangedEventArgs provides access to the old and new values of the Entry Text via the OldTextValue and NewTextValue properties:

void Entry_TextChanged (object sender, TextChangedEventArgs e)
    var oldText = e.OldTextValue;
    var newText = e.NewTextValue;

The TextChanged event can be subscribed to in XAML:

<Entry TextChanged="Entry_TextChanged" />

and C#:

var entry = new Entry ();
entry.TextChanged += Entry_TextChanged;