Chapter 14. Text and Flow Documents

Text in WPF applications need never be plain. Any place a user interface displays text, all of WPF’s text rendering features are available. Basic text formatting is offered, including word wrapping, text alignment, and any mixture of fonts and text styles. Nontextual UI elements such as controls or graphics may be intermingled with text. ClearType text rendering is used on flat-panel screens, significantly enhancing the clarity, shape, and readability of characters. The various typography features available in OpenType fonts can be exploited. And, as you would expect, there is full support for international applications.

As well as enabling fine control over textual details, WPF also defines types that represent documents. It offers two kinds: fixed documents and flow documents. Fixed documents have a fixed layout and size, and are often created in order to be printed. These are described in Chapter 15. Flow documents are more flexible—instead of prescribing a particular layout, they are formatted dynamically to fit the space available. This makes them ideal for presenting text on-screen, because most applications cannot know in advance the exact dimensions of the end user’s screen, or whether the user will resize her window.

In this chapter, we will explore the options for presenting text, and we will examine the object model used by flow documents.

Fonts and Text Styles

You can work with text at several levels in WPF, but regardless of which level ...

Get Programming WPF, 2nd Edition now with O’Reilly online learning.

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