Unlike Inline elements, Block elements take up the entire width of the text column and have line breaks before and after their content. By far, the most common block element is Paragraph.

Here are the elements that shipped with WPF that derive from Block:

  • Paragraph: With a straightforward name, this element (along with TextBlock) is the only container for Inline elements.
  • Section: A container for other Block elements — analogous to Span, which contains Inline elements.
  • BlockUIContainer: A container for UIElement-derived classes to be displayed as a block. Analogous to InlineUIElement.
  • List: Creates an ordered or unordered list. Contains ListItem elements.
  • Table: Contains TableRowGroup elements.

Additionally, there are a few helper classes that are a bit block-ish:

  • ListItem: Block container for use within a List.
  • TableRowGroup: Container for TableRow objects.
  • TableRow: Container for TableCell objects.
  • TableCell: Block container for use within a TableRow.

Just like the inline elements, all of these elements do not derive from UIElement or Visual — this is because they do not have a one-to-one mapping between their content and visuals on screen. The reasons for this, and their ramifications, will have to wait for the next post.

Differences from HTML

  • No nested paragraphs: It’s worth re-iterating, because you’ll probably run into it some time.
  • Strict structure for Lists and Tables: WPF is strict about the structure of Lists and, in particular, Tables. This leads to verbose markup.
  • Only one List: Unlike HTML, there are no specialized elements for ordered and unordered list. You use the MarkerStyle property.
  • Jonah
    Enough with this useless WPF info. Get back to the cheese!
blog comments powered by Disqus