Reputation: 135
i want to scroll page up and page down in wpf richextbox.i tried
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);
But it continuously scroll each line beginning,if current offset value move to non visible area in richtextbox,i want to move page up or page down not a single line by line scroll.
Note: I also tried BringIntoView();
FrameworkContentElement fce = (textRange.Start.Parent as FrameworkContentElement);
if (fce != null)
{
fce.BringIntoView();
}
its not working after i using textrange.clearallproperties()
.Before that it works.
So,kindly let me know how to scroll pageup and pagedown?
Regards Bala
Upvotes: 0
Views: 455
Reputation: 1620
Scroll down one page:
EditingCommands.MoveDownByPage.Execute(null, yourRichTextBox);
Scroll up one page:
EditingCommands.MoveUpByPage.Execute(null, yourRichTextBox);
Upvotes: 0