Перейти к основному содержимому
Версия: 11.0.0

Text Box

The text box presents an area for typed (keyboard) input. It can be for a single or multiple lines of input.

Useful Properties

You will probably use these properties most often:

PropertyDescription
TextThe current text in the input.
PasswordCharHides any characters typed, and replacing them with the given character instead.
WatermarkAppears as a faded hint whenever the input is empty.
AcceptsReturnMakes the input multi-line by allowing the user to enter line returns. A vertical scrollbar will appear if the content exceeds the height available.
TextWrappingDefines how horizontal line overflow will be handled. Options are: 'NoWrap', 'Wrap' and 'WrapWithOverflow'.

Example

This example has a basic one line text box, a password box, and a text-wrapping multiline text box:

<StackPanel Margin="20">
<TextBlock Margin="0 5" >Name:</TextBlock>
<TextBox Watermark="Enter your name"/>
<TextBlock Margin="0 5" >Password:</TextBlock>
<TextBox PasswordChar="*" Watermark="Enter your password"/>
<TextBlock Margin="0 15 0 5">Notes:</TextBlock>
<TextBox Height="100" AcceptsReturn="True" TextWrapping="Wrap"/>
</StackPanel>

More Information

к сведению

For the complete API documentation about this control, see here.

к сведению

View the source code on GitHub TextBox.cs