Adorner in WPF Textbox RRS feed

  • Question

  • I have created an adornerlayer over wpf textbox.

    This code block will return the bounds of the text in textbox, i have written this block in onrender method of a adorner class.

    Rect startPosition = textBox.GetRectFromCharacterIndex(startingCharOfAWord);
    Rect endPosition = textBox.GetRectFromCharacterIndex(endingCharOfAWord,true);
    Rect rectUnion = Rect.Union(startPosition, endPosition);

    using this(rectPosition) position i can highlight the text in the textbox.

    My Question : My textbox has more than 500 words. I need to scroll to read the text in the textbox. while scrolling in it, i used PreviewMouseWheel Event to update the adorner layer. But Rect returns empty. So i can't able get the bounds of the text.

    Suggest me an idea to get Rect value of the text when scrolling the text in the texbox.

    Monday, July 13, 2020 7:25 AM

All replies

  • Hi Naveen_047,

    Since your question is more related to WPF, so I suggest you post your question in WPF forum where you can get more efficient and professional responses.


    Thank you for your understanding.

    Best Regards,

    Xingyu Zhao

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, July 13, 2020 9:38 AM