I am coding a scroll bar with mark (like Visual Studio) and I want to be able to put a mark when i do a find (Ctrl+F) for a richtextbox. My user control is a scrollViewer with a contentPresenter, then in my window I put my content in the contentPresenter.
For now, I am able to find all the pattern i want with this code. But now, I want to add a mark on my scrollbar.
My algorithm to put mark is base on the position of the element I want to mark. So I would like to get the position from the top of the richtextbox or his parent (in my case it's a contentPresnter).
At beginning, I tought about getting the row of my string, but I can't cause it's a richtextbox and one line can have font size 48 and the next 12.
SOLUTION
I end up with one of the idea of Furkle. I use the RichTextBox.CaretPosition.GetCharacterRect(...) to get the Y and the Height property of the Rect.