I'm adding Inlines to a TextBlock. The Run() inlines work. Of course the Hyperlink() is deprecated in Windows 8 (using Windows.UI.Xaml.Documents) for some reason, so I'm trying to encapsulate a HyperlinkButton in an InlineUIContainer using C#. I know the concept is sound, but my code is failing.
if I comment out the line "using Windows.UI.Xaml.Documents;" then I get the two surrounding inlines to show up in my ListView (which uses the method below.) If this line is uncommented, the Inlines.Add for 'link' is throwing. What am I doing wrong?
public TextBlock enrichPostText(anFullPost post) { TextBlock text_block = new TextBlock(); text_block.Inlines.Clear();
var holdText = new Run();
holdText.Text = "Test start >> ";
text_block.Inlines.Add(holdText);
HyperlinkButton linkButton = new HyperlinkButton();
linkButton.NavigateUri = new Uri("http://www.cones.net");
linkButton.Content = "click me";
linkButton.Name = "_blank";
InlineUIContainer link = new InlineUIContainer();
link.Child = linkButton;
text_block.Inlines.Add(link);
var holdText2 = new Run();
holdText2.Text = " << end test.";
text_block.Inlines.Add(holdText2);
return (text_block);
}
I just tried changing my
RichTextBlock
to aTextBlock
, and I'm also seeing anArgumentException
get thrown when I try to add theInlineUIContainer
. The only solution I know is to useRichTextBlock
instead; so far it's been suiting my needs.