1. Get the current scroll bar position
// gets the current scroll bar position Richtextbox.verticaloffset;richtextbox.horizontaloffset;
// gets the current cursor position richtextbox.caretposition
2. Scroll to start, end, specify position
// //Summary://sets the view of the edit control to the end of the content. Public voidScrolltoend (); // //Summary://The view of the edit control to the beginning of the viewport. Public voidScrolltohome (); // //Summary://saves the contents of the edit control to the specified horizontal offset. // //Parameters://Offset://A Double value that specifies the horizontal skew of the scroll. Public voidScrolltohorizontaloffset (Doubleoffset); // //Summary://saves the contents of the edit control to the specified vertical offset. // //Parameters://Offset://A Double value that specifies the vertical offset of the scroll. Public voidScrolltoverticaloffset (DoubleOffset);
3. You can scroll to the position of an element by using the Bringintoview method.
DependencyObject currobj = as FrameworkElement; if NULL ) { fe. Bringintoview ();} Else { as frameworkcontentelement; if NULL ) { FCE. Bringintoview (); }}
How WPF RichTextBox Scroll to the cursor position, scroll bar action