FlowDocument - 重置进入视图

时间:2015-01-18 11:05:10

标签: c# wpf viewport

我的XAML文件中有以下代码:

<FlowDocumentScrollViewer Name="fd_ScrollViewer" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto">
      <FlowDocument PagePadding="10" FontFamily="Segoe UI" FontSize="21.5">
            <Paragraph Name="fdParagraph"></Paragraph>
      </FlowDocument>
</FlowDocumentScrollViewer>

对于Paragraph组件,在后面的代码中,我使用Run类型的大文本初始化段落,其中我不时地将视图添加到Run元素中。 但是,我的问题是我无法将视口重置为内容的开头。 这是我试过的:

    private void ResetBringIntoView() {
        // current run element is Run element with 0 Index in Paragraph Inline
        if (fdParagraph.FlowDirection == System.Windows.FlowDirection.LeftToRight) {
            fdParagraph.FlowDirection = FlowDirection.RightToLeft;
            CurrentRunElement.BringIntoView();
        }         
        else {
            fdParagraph.FlowDirection = FlowDirection.LeftToRight;
            CurrentRunElement.BringIntoView();
        }
    }

但这并没有奏效。

0 个答案:

没有答案