[英]Stop hyperlink in TextBlock from opening browser
I need to stop the Browser from opening when a Hyperlink is clicked inside a Textblock. 单击文本块内的超链接时,我需要停止打开浏览器。 Here is the XAML:
这是XAML:
<TextBlock Name="text" FontSize="40" TextWrapping="Wrap"/>
Here I Create the Hyperlink inside the Textblock: 在这里,我在文本块内创建了超链接:
link.NavigateUri = new Uri("http://google.de");
link.Inlines.Add(new Run { Text = "http://google.de" });
link.Click += link_Click;
text.Inlines.Add(link);
This is my link_Click function: 这是我的link_Click函数:
void link_Click(Hyperlink sender, HyperlinkClickEventArgs args)
{
System.Diagnostics.Debug.WriteLine("print this instead of opening link in browser");
}
The text gets printed but the webbrowser opens too. 文本被打印,但Web浏览器也打开。 Any way to stop the browser from opening?
有什么方法可以阻止浏览器打开?
如果您不希望HyperLInk导航(打开浏览器),则只需删除Hyperlink.NavigateUri即可 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.