0

我想知道如何使用 webbrowser 设置文本框的值。例如,我想打开谷歌搜索页面和自动完成搜索文本框到特定值。我发现在 win 表单中我可以使用 GetElementById 和 SetAttribute 方法来做到这一点。不幸的是,我不能在 wpf 中使用这种方法。

4

1 回答 1

1

WPF 中的 WebBrowser 控件当前不支持此功能。但是,您可以使用“WindowsFormsHost”控件在 WPF 应用程序中使用 WinForms WebBrowser。

像这样:

<Window 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms">
    <Grid>
      <WindowsFormsHost>
        <wf:WebBrowser />
      </WindowsFormsHost>
    </Grid> 
</Window>
于 2012-05-30T18:41:17.157 回答