Share via

FlowDocument GetCharRect returning infinity for top, bottom, left right - How get rectangle for offset position from document

joe blow 1 Reputation point
2022-07-17T18:26:25.817+00:00

Sometimes GetCharRect return a negative or positive infinity for the top,right bottom and left positions.
Is there a way to get the rectangle for a character at offest position from the start of the document without the CarorPosition having to point it or the offset position being selected?

Developer technologies | Windows Presentation Foundation
Developer technologies | XAML
Developer technologies | XAML

A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.

0 comments No comments

1 answer

Sort by: Most helpful
  1. joe blow 1 Reputation point
    2022-07-17T18:33:00.9+00:00

    No matter what the offset value is top,right bottom and left positions
    richTextBox.CaretPosition.GetPositionAtOffset(163).GetCharacterRect(LogicalDirection.Forward) {Empty} System.Windows.Rect

    The Selection is an empty string.

    	richTextBox.Selection	{System.Windows.Documents.TextSelection}	System.Windows.Documents.TextSelection  
    	Text	""	string
    

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.