0

I have following FlowDocument with Paragraph in my XAML file:

<FlowDocumentScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto">
    <FlowDocument Name="fDocument" PagePadding="10" FontFamily="Segoe UI" FontSize="22">
        <Paragraph Name="fdParagraph">
            Those who have denied the reality of moral distinctions, may be
            ranked among the disingenuous disputants; nor is it conceivable,
            that any human creature could ever seriously believe, that all
            characters and actions were alike entitled to the affection and
            regard of everyone. The difference, which nature has placed
            between one man and another, is so wide, and this difference is
            still so much farther widened, by education, example, and habit,
            that, where the opposite extremes come at once under our
            apprehension, there is no scepticism so scrupulous, and scarce
            any assurance so determined, as absolutely to deny all
            distinction between them. Let a man's insensibility be ever so
            great, he must often be touched with the images of Right and
            Wrong; and let his prejudices be ever so obstinate, he must
            observe, that others are susceptible of like impressions. The
            only way, therefore, of converting an antagonist of this kind, is
            to leave him to himself.
        </Paragraph>
    </FlowDocument>
</FlowDocumentScrollViewer>

Basically, what I want to achieve is to, on each click, highlight next text part. For example:

Click -> Those

Click -> who

Click -> have

I understand that I need first to split this paragraph into text parts, spliting it by empty space character, and then storing parts into array, but I don't know which methods from Paragraph class can help me to get this to work.

So, how do I achieve to highlight next text part in paragraph ?

Kapparino
  • 988
  • 11
  • 33
  • Iterate over the `Run` Children of the Paragraph and set their `Background` or `Foreground`? – Clemens Jan 09 '15 at 10:18
  • How do I get Run Childrens of the Paragraph? – Kapparino Jan 09 '15 at 10:23
  • 1
    Sorry, it's called Inlines: `foreach (var run in paragraph.Inlines.OfType()) { ... }` – Clemens Jan 09 '15 at 10:26
  • Thanks for this. Now last question, how do I highlight next text part in paragraph ? How do I select text part like from example I gave up ? – Kapparino Jan 09 '15 at 10:34
  • 1
    As you already said: "I understand that I need first to split this paragraph into text parts". You would create an InlineCollection that contains each text part as a single Run. Keep the index of the current item, on click step to the next one. – Clemens Jan 09 '15 at 10:37

0 Answers0