You can use Mouse.GetPosition(MyRichTextBox)that will return you the X, Y coordinates of the mouse in the RichTextBox
Here is a simple example that I used to validate:
<StackPanel>
<RichTextBox x:Name="Test" Height="100" Width="100" MouseMove="Test_MouseMove" />
<Label x:Name="Test2" Content="{Binding }" />
</StackPanel>
Code for:
private void Test_MouseMove(object sender, MouseEventArgs e)
{
this.Test2.DataContext = Mouse.GetPosition(this.Test);
}
EDIT
I didn’t understand that you want to get the caret position instead of the mouse position. Use myRichTextBox.CaretPosition.GetCharacterRect(LogicalDirection.Forward)to get carriage X, Y coordinates
source
share