【发布时间】:2016-04-19 09:44:55
【问题描述】:
我在 wpf Richtextbox 中工作。使用下面的函数用于向上翻页。
TextRange range10 = new TextRange(txtAppendValue.CaretPosition.GetLineStartPosition(1), txtptrCaret);
FrameworkContentElement fce1 = (range10.End.Parent as FrameworkContentElement);
if (fce1 != null)
{
fce1.BringIntoView();
range10 = null;
fce1 = null;
}
它的工作。在我清除了richtextbox并加载了一些其他内容之后,当时显示的内容是上次页面发生的位置?当我重新加载文档时如何清除。
更新:
public void HideTopBorder()
{
TextPointer currentline = txtAppendValue.CaretPosition.GetLineStartPosition(1);
System.Windows.Rect rc = currentline.GetCharacterRect(LogicalDirection.Forward);
System.Windows.Point upperLeftCorner = rc.Location;
HitTestResult result = VisualTreeHelper.HitTest(txtAppendValue, upperLeftCorner);
if (result == null)
{
Thickness margin = txtAppendValue.Margin;
margin.Top = -20;
txtAppendValue.Margin = margin;
currentline = null;
}
else
{
currentline = null;
}
}
在结果 null 之后只发生了 pageup。当时我清除了文档并加载了另一个文档。但是现在显示已经平移的点的 Richtextbox。而不是文档的顶部。
问候 阿琼
【问题讨论】:
-
任何人都可以请...
标签: c# wpf scroll richtextbox panning