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:

  1. Create a new WPF application named CH04.TextControls.
  2. Open MainWindow.xaml. Add four rows and two columns to the existing Grid:
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto"/>
        <RowDefinition />
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>
  3. Add some controls ...

Get Windows Presentation Foundation 4.5 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.