O'Reilly logo

Windows Application Development Cookbook by Marcin Jamro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding a text block

Very often, it is necessary to show some labels on the page. Such a task can be accomplished using the TextBlock control, which is the main subject of this recipe. Here, you will learn how to display static text on the page as well as how to format it.

Getting ready

To step through this recipe, you only need the automatically generated project.

How to do it...

To add a text block and handle the Tapped event, perform the following steps:

  1. Place the TextBlock control on the page and adjust its appearance by modifying the content of the MainPage.xaml file as follows:
            <Page (...)> 
                <Grid (...)> 
                    <TextBlock Text="Exemplary justified content (...)" TextAlignment="Justify" MaxLines="3" TextTrimming="CharacterEllipsis" TextWrapping="Wrap" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required