如何显示 FlowDocument 的一部分?

How to show a part of a FlowDocument?

我需要缩短显示在 FlowDocument ScrollViewer 中的 FlowDocument。

显示:Lorem ipsum 坐着痛,自负旅行sadipscing elitr.

应该显示:Lorem ipsu...

我该怎么做?

我是这样做的。如果 FlowDocument 的长度超过 "maxLength":

,则会对其进行修剪
var wholeTextRange = new TextRange(doc.ContentStart, doc.ContentEnd);
if (wholeTextRange.Text.Length > maxLength)
{
    TextPointer endPos = doc.ContentStart.GetPositionAtOffset(maxLength);
    var textRange = new TextRange(endPos, doc.ContentEnd);
    textRange.Text = "...";
}