arjun sanju
arjun sanju

Reputation: 135

WPF Richtextbox scroll one page up and down?

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

Answers (1)

Pollitzer
Pollitzer

Reputation: 1620

Scroll down one page:

EditingCommands.MoveDownByPage.Execute(null, yourRichTextBox);

Scroll up one page:

EditingCommands.MoveUpByPage.Execute(null, yourRichTextBox);

Upvotes: 0

Related Questions