Providing a user option to input text
The TextBox
control in WPF is used to allow the user to input plain text in a single line or multiline format. A single-line textbox is the commonly used control for form inputs; whereas the multiline textbox is used like an editor.
Getting ready
Open your Visual Studio IDE, and create a new project named CH02.TextBoxDemo
, based on the WPF application template.
How to do it...
Once the project gets created, follow the mentioned steps to play with some of the TextBox
properties:
- Open the
MainWindow.xaml
page, and replace the defaultGrid
with aStackPanel
so that we can add the controls in a stacked fashion. - Now add five
TextBox
controls inside theStackPanel
, and set various properties, as follows:
<StackPanel Margin="10 10 10 20"> <TextBox Height="30" Margin="10 5" Text="Hello"/> <TextBox Text="Hello WPF!" FontSize="18" Foreground="Blue" FontWeight="Bold" Height...