locked
How to determine the selectable region of a RichTextBlock?

    Question

  • Hello,

    Let's say I have a RichTextBlock of width 200 and I have an inline run that wraps, I want to be able to determine the selectable region. More specifically, how can I determine what region the Run occupies on Line 1, Line 2, etc?

    <RichTextBlock Width="200" FontSize="20" TextWrapping="Wrap">
        <RichTextBlock.Blocks>
            <Paragraph >
                <Paragraph.Inlines>
                    <Run Text="My selectable run" />
                </Paragraph.Inlines>
            </Paragraph>
        </RichTextBlock.Blocks>
    </RichTextBlock>

     


    • Edited by Dev Help Friday, August 8, 2014 11:26 PM
    Friday, August 8, 2014 11:10 PM

Answers

  • Hi Dev Help,

    By ElementStart  and  ElementEnd from Run class we should be able to know the TextPointer position of the Run block. But I cannot see there exist any method that can get the line number of the selectable region, or even any valuable that can calculate the line number.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by Dev Help Monday, August 11, 2014 10:05 AM
    Monday, August 11, 2014 6:04 AM
    Moderator