TextPointer start = myRichTextBox.Selection.Start.GetNonMergeableInlinePosition(LogicalDirection.Forward); TextPointer end = myRichTextBox.Selection.End.GetNonMergeableInlinePosition(LogicalDirection.Backward); string paragraphText = TextRange(start, end).Text;
TextPointer pointer = myRunElement.ContentStart; string runText = pointer.GetTextInRun(LogicalDirection.Forward);In both examples, we are using the ITextPointer.GetNonMergeableInlinePosition method to get the starting and ending positions of the text run. Then, we are using the GetTextInRun method to get the text contained within the text run. Package library: System.Windows.Documents.