如何使用 WPF 加载网页
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12009913/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to load a web page using WPF
提问by Luke101
I need to load a web page in WPF and interact with the elements in the page. Is there a way to do this with WPF?
我需要在 WPF 中加载一个网页并与页面中的元素进行交互。有没有办法用 WPF 做到这一点?
回答by Tudor
You could try use the WebBrowsercontrol. This basically provides you with a web browser inside your app and you can then load and navigate through web pages.
您可以尝试使用WebBrowser控件。这基本上在您的应用程序中为您提供了一个网络浏览器,然后您可以加载和浏览网页。
Just place the control with
只需放置控件
<WebBrowser Name="webBrowser" />
and then
进而
webBrowser.Navigate("http://www.stackoverflow.com");
回答by Talles Penini
You can use
您可以使用
<WebBrowser Source="http://www.microsoft.com" />
回答by Rodrigo Guedes
Add a WebBrowser control to your WPF and load a web page using the Navigate method:
将 WebBrowser 控件添加到 WPF 并使用 Navigate 方法加载网页:
webBrowser1.Navigate("http://www.google.com");

