首页 > 其他分享 >WPF FlowDocument Paragraph

WPF FlowDocument Paragraph

时间:2024-09-28 15:13:01浏览次数:1  
标签:Blocks FlowDocument Inlines collection content Paragraph text WPF

<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>

 

 

 

 

 

 

 

标签:Blocks,FlowDocument,Inlines,collection,content,Paragraph,text,WPF
From: https://www.cnblogs.com/Fred1987/p/18437985

相关文章

  • C# + WPF 音频播放器 界面优雅,体验良好
    阅读目录前言项目介绍项目页面项目源码项目地址最后前言本文介绍一款使用C#与WPF开发的音频播放器,其界面简洁大方,操作体验流畅。该播放器支持多种音频格式(如MP4、WMA、OGG、FLAC等),并具备标记、实时歌词显示等功能。另外,还支持换肤及多语言(中英文)切换。核心音频......
  • WPF canvas Draw line , ellipse and rectangle, save canvas and contents as pictu
    //xaml<Windowx:Class="WpfApp417.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.mi......
  • wpf ToggleButton选中效果和一个登录界面
    先看效果 我修改了ToggleButton的ControlTemplate,在ContentPresenter外面加了4个Border,控制4个Border的位置在ControlTemplate的左上、右上、左下、右下,选中时,触发4个边框的BorderThickness<SetterProperty="BorderThickness"TargetName="brd......
  • WPF InkCanvas selection mode, save all/selected strokes, load strokes file, sav
    //xaml<Windowx:Class="WpfApp416.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.mi......
  • WPF Panel超出边界
    关于StackPanel和Grid这两种常用的WPF布局控件的不同行为1.StackPanel的行为:StackPanel设计用于简单地将元素堆叠在一起(垂直或水平)。它不会限制其子元素的大小,允许它们按需增长。这意味着:子元素可以超出StackPanel的边界StackPanel不会自动调整大小以适应其内容如果内......
  • DevExpress WPF中文教程:如何解决编辑单元格值的常见问题?
    DevExpressWPF拥有120+个控件和库,将帮助您交付满足甚至超出企业需求的高性能业务应用程序。通过DevExpressWPF能创建有着强大互动功能的XAML基础应用程序,这些应用程序专注于当代客户的需求和构建未来新一代支持触摸的解决方案。无论是Office办公软件的衍伸产品,还是以数据为中心......
  • WPF Error XLS0108 Entity references or sequences beginning with an ampersand '&'
    //https://img1.baidu.com/it/u=3991277133,2041185316&fm=253 <ImageSource="https://img1.baidu.com/it/u=3991277133,2041185316&fm=253"/>SeverityCodeDescriptionProjectFileLineSuppressionStateDetailsErr......
  • wpf ToggleButton选中效果
    先看效果 <StyleTargetType="{x:TypeToggleButton}"><SetterProperty="Background"Value="Transparent"/><SetterProperty="BorderBrush"Value="DarkGray"/><......
  • C# + WPF 音频播放器 界面优雅,体验良好
    C#+WPF音频播放器界面优雅,体验良好 合集-.NET开源工具(18)  阅读目录前言项目介绍项目页面项目源码项目地址最后前言本文介绍一款使用C#与WPF开发的音频播放器,其界面简洁大方,操作体验流畅。该播放器支持多种音频格式(如MP4、WMA、OGG、FLAC......
  • .NET 6.0 + WPF 使用 Prism 框架实现导航
    .NET6.0+WPF使用Prism框架实现导航 合集-.NET基础知识(4) 1..NET9优化,抢先体验C#13新特性08-202.《黑神话:悟空》神话再现,虚幻引擎与Unity/C#谁更强?08-213..NET6.0+WPF使用Prism框架实现导航09-114.2024年C#高效开发:精选实用类库09-23收起 ......