我想知道如何使用webbrowser设置文本框的值。例如,我想打开谷歌搜索页面并自动完成搜索文本框到特定值。我发现在win表单中我可以使用GetElementById和SetAttribute方法来完成它。不幸的是我无法在wpf中使用这种方法。
答案 0 :(得分: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>