Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to retrieve text from RichTextBlock in WinRT
    text
    copied!<p>I am using the standard RichTextColumns.cs helper class that is added by VS2012's default Metro Style project template. It uses the RichTextBlock internally to add RichTextColumns. DataBinding is working fine with the following markup</p> <pre><code>&lt;common:RichTextColumns&gt; &lt;common:RichTextColumns.ColumnTemplate&gt; &lt;DataTemplate&gt; &lt;RichTextBlockOverflow Width="400" Margin="50,0,0,0"/&gt; &lt;/DataTemplate&gt; &lt;/common:RichTextColumns.ColumnTemplate&gt; &lt;RichTextBlock Width="400"&gt; &lt;Paragraph&gt; &lt;Run Text="{Binding Content}"/&gt; &lt;/Paragraph&gt; &lt;/RichTextBlock&gt; </code></pre> <p></p> <p>Now I have the embedded hyperlinks in 'Content' that are not treated as hyperlinks in WinRT. I need them to behave like hyperlinks. So I want to retrieve the text that's getting bound to the RichTextBlock, tokenize it, insert InlineUI elements that have the HyperlinkButton at appropriate places. Now I could do all this if I could only retrieve the text that is getting bound to the RichTextBlock. Unfortunately I can't seem to 'retrieve' it.</p> <p>I tried</p> <pre><code>RichTextBlock value = (RichTextBlock)GetValue(RichTextContentProperty); valueRun = (Run)((Paragraph)value.Blocks[0]).Inlines[0]; value.Select(((Paragraph)value.Blocks[0]).ContentStart, ((Paragraph)value.Blocks[0]).ContentEnd); Paragraph para = TokenizeTweet(value.SelectedText); </code></pre> <p>But the SelectedText is always empty. However if I do a <code>value.Blocks.Clear()</code><br> it clears out the text that is getting bound. What am I missing?</p> <p>Simply put, how to retrieve unformatted text from a RichTextBlock in WinRT (Not WPF or Silverlight).</p> <p>Thanks and Regards, Sumit.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload