WPF FlowDocument Paragraph
<Window x:Class="WpfApp418.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfApp418" mc:Ignorable="d" WindowState="Maximized" Title="MainWindow" Height="450" Width="800"> <FlowDocument> <Paragraph FontSize="22" FontWeight="Bold">Chapter 1</Paragraph> <Paragraph FontSize="35" FontWeight="Bold">Why WPF?</Paragraph> <Paragraph> In movies and on TV,Two main types of TextElements exist—Blocks and Inlines. (Both of these are abstract classes derived from TextElement.) A Block is a rectangular region that can’t be separated (except when it spans multiple pages), whereas an Inline is a region that flows more freely with text, potentially occupying a nonrectangular space (flowing from the end of one line to the beginning of the next). FlowDocument supports only Blocks, such as Paragraph, as its children. (Its content property is called Blocks, which is a BlocksCollection.) We’ll look at the role of Inlines after examining Blocks more closely. WPF has five different types of Blocks: . Paragraph—Has a collection of Inlines, which typically contain the “meat” of the document. In XAML, you often see Paragraph’s content set to simple text, but internally an Inline called Run is created with that content and added to the Paragraph’s Inlines collection, just like with TextBlock. . Section—Groups one or more Blocks together without imposing any additional structure. This is handy if you want to set the same property values for multiple Blocks, such as a Background and Foreground. . List—Presents a collection of ListItems as a bulleted, numbered, or plain list. Each ListItem can contain a collection of Blocks, so creating a typical text-based List involves placing a Paragraph inside each ListItem. List’s MarkerStyle property (of type TextMarkerStyle) provides plenty of formatting options for bullets—Box, Circle, Disc (the default bullet), and Square—and for numbers—Decimal, LowerLatin, UpperLatin, LowerRoman, and UpperRoman. A plain list can be achieved by setting MarkerStyle to None. . Table—Organizes content into rows and columns, sort of like Grid but closer to an HTML TABLE. Table, unlike Grid, can contain only Blocks (and elements defining the Table’s structure). In movies and on TV,Two main types of TextElements exist—Blocks and Inlines. (Both of these are abstract classes derived from TextElement.) A Block is a rectangular region that can’t be separated (except when it spans multiple pages), whereas an Inline is a region that flows more freely with text, potentially occupying a nonrectangular space (flowing from the end of one line to the beginning of the next). FlowDocument supports only Blocks, such as Paragraph, as its children. (Its content property is called Blocks, which is a BlocksCollection.) We’ll look at the role of Inlines after examining Blocks more closely. WPF has five different types of Blocks: . Paragraph—Has a collection of Inlines, which typically contain the “meat” of the document. In XAML, you often see Paragraph’s content set to simple text, but internally an Inline called Run is created with that content and added to the Paragraph’s Inlines collection, just like with TextBlock. . Section—Groups one or more Blocks together without imposing any additional structure. This is handy if you want to set the same property values for multiple Blocks, such as a Background and Foreground. . List—Presents a collection of ListItems as a bulleted, numbered, or plain list. Each ListItem can contain a collection of Blocks, so creating a typical text-based List involves placing a Paragraph inside each ListItem. List’s MarkerStyle property (of type TextMarkerStyle) provides plenty of formatting options for bullets—Box, Circle, Disc (the default bullet), and Square—and for numbers—Decimal, LowerLatin, UpperLatin, LowerRoman, and UpperRoman. A plain list can be achieved by setting MarkerStyle to None. . Table—Organizes content into rows and columns, sort of like Grid but closer to an HTML TABLE. Table, unlike Grid, can contain only Blocks (and elements defining the Table’s structure). </Paragraph> </FlowDocument> </Window>