Skip to Main Content
Programming WPF, 2nd Edition
book

Programming WPF, 2nd Edition

by Chris Sells, Ian Griffiths
August 2007
Intermediate to advanced content levelIntermediate to advanced
864 pages
25h 52m
English
O'Reilly Media, Inc.
Content preview from Programming WPF, 2nd Edition

Text Object Model

Text has distinctive layout requirements. With most user interface elements, the goal of layout is typically to define the basic UI structure (e.g., menu and toolbars at the top, status bar at the bottom, tree view on the left, scrollable work area on the right) and have the layout system make simple adjustments to the size and position of each element in order to fit the available space. But with text, we typically have a continuous stream of content where sequencing is more important than exact position. For example, we often don't care whether a particular figure appears at the top, bottom, or middle of a page as long as it is adjacent to the paragraph that refers to the figure.

There is some overlap between the requirements of text layout and UI layout. For example, the WrapPanel arranges elements in a similar manner to word-wrapped text layout. Although it would have been technically possible to use a single layout system for both textual content and user interface structure, this would have involved compromises on both sides. WPF's object model for representing formatted text is therefore separate from the layout panels and controls we've seen in previous chapters.

The element types that make up the text model all derive from a common abstract base class: TextElement. As you saw in Table 14-1, this defines a set of properties for controlling aspects of the text's appearance, such as its font and color. The TextElement type does not derive from FrameworkElement ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming C#, 4th Edition

Programming C#, 4th Edition

Jesse Liberty
Programming C# 10

Programming C# 10

Ian Griffiths

Publisher Resources

ISBN: 9780596510374Supplemental ContentErrata Page