public static Rect GetTextPositionInViewPort(TextView textView, TextViewPosition position)
{
if (position.Line - 1 < textView.VisualLines.Count)
{
return new Rect(textView.VisualLines[position.Line - 1].RenderedText.HitTestTextPosition(position.Column - 1).X + textView.TextSurfaceBounds.X,
textView.CharSize.Height * (position.Line - 1),
textView.CharSize.Width,
textView.CharSize.Height);
}
return new Rect(textView.TextSurfaceBounds.X + textView.CharSize.Width * (position.Column - 1),
textView.CharSize.Height * (position.Line - 1),
textView.CharSize.Width,
textView.CharSize.Height);
}