有没有办法通过索引从流文档中检索单个块?

Is there a way to retrieve a single block from a flowdocument by index?

我创建了一个流程文档并添加了一些块。我现在需要根据索引值访问块。 IE。我需要第一段,或者第二段。

如何获得给定索引的特定块?

我终于设法解决了这个问题。

首先,我为积木创建了一个列表

List<Block> Pblocks = new List<Block>();
Pblocks = TailoredResources_Reading_Text.Document.Blocks.ToList();

然后,我将块分配给一个段落

Paragraph paragraph = Pblocks[1] as Paragraph;

最后,使用 运行 通过列表获取第一个内联

Run sText = paragraph.Inlines.ToList()[0] as Run;