Reputation: 135
i am working in wpf richtextbox.use the below function use for page up.
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;
}
its working.After i clear the richtextbox and load some other content,at that time the content shown where the pageup happened in last time?how to clear when i reload the document.
Updated:
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;
}
}
After the result null only pageup happened.at that time i clear the document and load an another document.But now show the richtextbox where the already panned point.not top of the document.
Regards Arjun
Upvotes: 1
Views: 65
Reputation: 1620
Before you load a new document save the value of rtb.VerticalOffset
. Then load the new document and reassign the stored value to rtb.VerticalOffset
.
Upvotes: 1