Working with text
Text is the most fundamental way of conveying and inputting information. WPF provides a bunch of elements and controls that allow text display and input.
Getting ready
Make sure Visual Studio is up and running.
How to do it...
We'll create a simple application that uses the more common text related controls to demonstrate their usage:
Create a new WPF application named
CH04.TextControls
.Open
MainWindow.xaml
. Add four rows and two columns to the existingGrid
:<Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto"/> <RowDefinition /> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition /> </Grid.ColumnDefinitions>
Add some controls to the grid as follows:
<TextBlock FontSize="16" Text="User comment details" Margin="4" Grid.ColumnSpan="2" HorizontalAlignment="Center"...