WPF Web浏览器NavigateToString不显示字符串内容中的链接吗? [英] WPF webbrowser NavigateToString does not show links in the string content ?

查看:255
本文介绍了WPF Web浏览器NavigateToString不显示字符串内容中的链接吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在编写一个小的WPF应用程序,其中使用了Web浏览器控件.

我正在从db中获取一些段落,并通过使用webbrowser.NavigateTostring()方法将该段落放入broser控件中.


问题是,如果该段包含任何URL,则Web浏览器控件必须将该URL显示为超链接.

例如:正在浏览以下段落.

WebBrowser.NavigateToString(我经常通过http://www.codeproject.com进行更新.这非常有用.");

实际结果是:

我会定期通过http://www.codeproject.com更新.而且非常有用.

预期结果:

我会定期通过 http://www.codeproject.com 更新.而且非常有用.


任何帮助,不胜感激.

在此先感谢.
Mydeen

Hi All,

I am writing a small WPF application where I have used a web browser control.

I am getting some paragraph from db and putting the paragraph in the broser control by using webbrowser.NavigateTostring() method.


The problem is, in case the paragraph contains any URL, the web browser controls has to show that URL as a hyperlink.

Eg: Am navigating a paragraph as below.

WebBrowser.NavigateToString("I am regularly updating through http://www.codeproject.com. And It is very useful.");

Actual Result Is :

I am regularly updating through http://www.codeproject.com. And It is very useful.

Expected Result :

I am regularly updating through http://www.codeproject.com. And It is very useful.


Any help much appreciated.

Thanks in Advance.
Mydeen

推荐答案

当然!没有锚("a"元素)应显示为URL. Web浏览器无法读懂您的想法.它不会尝试猜测URL在哪里.不仅如此,您的文字不是HTML.

具有有效锚点元素的白色有效HTML,用于获取锚点,您可以单击并导航.
希望您能自己找到HTML标准...

参见:
http://msdn.microsoft.com/en-us/library/system.windows.controls.webbrowser.navigatetostring.aspx [ ^ ],请注意这一行如果text参数不是有效的HTML格式,它将显示为纯文本.".

—SA
Of course! There is no anchor ("a" element) which should show this is URL. Web browser does not read your mind. It does not try to guess where is the URL. More than that, your text is not HTML.

White valid HTML with valid anchor element to get the anchor you can click on and navigate.
Hope you will find HTML standard by yourself…

See:
http://msdn.microsoft.com/en-us/library/system.windows.controls.webbrowser.navigatetostring.aspx[^], pay attention to this line "If the text parameter is not in valid HTML format, it will be displayed as plain text.".

—SA


这篇关于WPF Web浏览器NavigateToString不显示字符串内容中的链接吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆