Я использую стандартный вспомогательный класс RichTextColumns.cs, который добавляется шаблоном проекта Metro Style VS2012 по умолчанию. Он использует RichTextBlock внутри для добавления RichTextColumns. DataBinding отлично работает со следующей разметкой
<common:RichTextColumns>
<common:RichTextColumns.ColumnTemplate>
<DataTemplate>
<RichTextBlockOverflow Width="400" Margin="50,0,0,0"/>
</DataTemplate>
</common:RichTextColumns.ColumnTemplate>
<RichTextBlock Width="400">
<Paragraph>
<Run Text="{Binding Content}"/>
</Paragraph>
</RichTextBlock>
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.
Я пытался
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);
Но SelectedText всегда пуст. Однако, если я делаю value.Blocks.Clear()
, он очищает текст, который связывается. Что мне не хватает?
Проще говоря, как получить неформатированный текст из RichTextBlock в WinRT (не в WPF или Silverlight).
Спасибо и С уважением, Сумит.