【问题标题】:WPF Richtextbox scroll one page up and down?WPF Richtextbox上下滚动一页?
【发布时间】:2016-01-28 04:19:10
【问题描述】:

我想在 wpf richextbox 中上下翻页。我试过了

var start = txtAppendValue.Selection.Start.GetCharacterRect(LogicalDirection.Forward);
               var end = txtAppendValue.Selection.End.GetCharacterRect(LogicalDirection.Forward);
               txtAppendValue.ScrollToVerticalOffset((start.Top + end.Bottom - txtAppendValue.ViewportHeight) / 2 + txtAppendValue.VerticalOffset);

但它连续滚动每一行开始,如果当前偏移值移动到richtextbox中的不可见区域,我想向上或向下移动页面而不是逐行滚动。

注意:我也试过 BringIntoView();

FrameworkContentElement fce = (textRange.Start.Parent as FrameworkContentElement);
            if (fce != null)
            {
                fce.BringIntoView();
            }

在我使用textrange.clearallproperties()之后它不起作用。在此之前它起作用了。

那么,请告诉我如何向上翻页和向下翻页?

问候 巴拉

【问题讨论】:

    标签: c# wpf scroll richtextbox


    【解决方案1】:

    向下滚动一页:

    EditingCommands.MoveDownByPage.Execute(null, yourRichTextBox);
    

    向上滚动一页:

    EditingCommands.MoveUpByPage.Execute(null, yourRichTextBox);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多