camlCase
camlCase

Reputation: 97

WPF RichTextBox - Parent element from caret position

Consider this document structure:

<FlowDocument><Paragraph>loreM Ipsum</Paragraph></FlowDocument>

And my caret position is between 'M' and 'I' in the RichTextBox. How can I get the parent element from caret position? In this case the parent would be the Paragraph.

Upvotes: 2

Views: 1218

Answers (1)

Quartermeister
Quartermeister

Reputation: 59139

RichTextBox.CaretPosition.Parent

I think the parent element in that case will actually be a Run, and the parent of the Run will be the Paragraph.

Upvotes: 3

Related Questions