开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜