In this article we are going to learn about the TextBox control and how to add controls to your Windows Store apps built for Windows using C#.

The XAML framework for Windows Store apps is designed for Windows using XAML and includes several controls for entering and editing text, and a set of properties for formatting the text; those properties are:

In this article I will show how to embed these text controls in your Windows Store application using XAML.

TextBox


A TextBox control is used to enter and edit unformatted text. You can set the Text either using deisgn or through coding. Here's some important properties of the TextBox control:
  • Text: It sets or gets the text of the control.
  • IsReadOnly: It accepts a boolean value to make the textbox readonly or not.
  • TextWrapping: This property enables to wrap the text in the textbox.
  • Selected Text: It is used to get or set the selected text in the textbox.
  • Accept Return: This property makes the textbox multiline. It accepts a boolean value.
Here is an example of these properties and methods in use.

XAML code:

<TextBox x:Name="textBox1" Height="75" Width="300" Margin="10" Text="Some Text" TextWrapping="Wrap" AcceptsReturn="True"/>


Output

Textbox-Control-In-windows-Store-apps.jpg

PasswordBox

The PasswordBox control is used to enter a password into the textbox. The user cannot view the entered text. It only displays a dot for each character in the text. Here are some important properties of the PasswordBox:

Here's an example of the password box control.

XAML code

<PasswordBox x:Name="pwBox" Height="35" Width="200" MaxLength="8" />


Output

passwordbox-control-in-windows-store-apps.jpg
RichEditBox

The RichEditBox control is used to enter and edit bulk text as formatted text, like documents. Here is some important properties of the RichEditBox control:

Here's an example of the password box control.

XAML code

<RichEditBox x:Name="RichEdit" Width="200" Height="100" AcceptsReturn="True" TextWrapping="Wrap" HorizontalAlignment="Left"/>

Output

richeditbox-control-in-windows-store-apps.jpg