I have a RichTextBox
in my WPF app, filled with colored text.
I want to make it programmatically go to the start of the document, so I followed msdn's recommandation:
TextPointer caretPos = RTB.CaretPosition;
caretPos = caretPos.DocumentStart;
RTB.CaretPosition = caretPos;
And that does precisely nothing...
I also tried:
RTB.Selection.Select(RTB.Document.ContentStart, RTB.Document.ContentStart);
Which didn't work either.
I couldn't find other information on the subject aside from another question in StackOVerflow, that remains unans开发者_JAVA技巧wered.
Anyone has a solution?
I thought it would be this:
rtb.CaretPosition = rtb.Document.ContentStart;
Seems to work for me.
Simple solution, don't touch the Caret! RTB.ScrollToHome(); did the deed.
精彩评论