C# 是否在wpf richtextbox中清除并重新加载内容后清除pageup/pagedown平移值?
我在wpf richtextbox中工作。使用下面的函数用于翻页C# 是否在wpf richtextbox中清除并重新加载内容后清除pageup/pagedown平移值?,c#,wpf,scroll,richtextbox,panning,C#,Wpf,Scroll,Richtextbox,Panning,我在wpf richtextbox中工作。使用下面的函数用于翻页 TextRange range10 = new TextRange(txtAppendValue.CaretPosition.GetLineStartPosition(1), txtptrCaret); FrameworkContentElement fce1 = (range10.End.Parent as FrameworkContentElement); if
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;
}
}
结果为空后,只发生了分页。当时我清除了文档并加载了另一个文档。但现在显示richtextbox,其中包含已平移的点。而不是文档的顶部
问候
Arjun加载新文档之前,请保存
rtb.VerticalOffset
的值。然后加载新文档并将存储的值重新分配到rtb.VerticalOffset
任何人都可以。。。