How can I create a hyperlink in C# code instead of XAML
How can I create a hyper link in C# code that looks like the following in XAML?:
&开发者_如何学编程lt;TextBlock>
<Hyperlink Click="HyperLinkClick">New Hyperlink</Hyperlink>
</TextBlock>
MSDN usually has very good examples. Combining the examples for TextBlock and Hyperlink:
TextBlock textBlock1 = new TextBlock();
Run run3 = new Run("Link Text.");
Hyperlink hyperl = new Hyperlink(run3);
hyperl.NavigateUri = new Uri("http://search.msn.com");
textBlock1.Inlines.Add(hyperl);
精彩评论