I have been trying to use Commands with the WPF WebBrowser
control (with DesignMode = "on"
):
<Window>
<Grid>
<Button Command="ToggleBold"/>
<WebBrowser />
</Grid>
</Window>
...but despite the WebBrowser
accepting keystrokes when I type (and formatting a word as bold when I hit Ctrl+B
) nothing happens when I click the button. This indicates to me that the WebBrowser
does not natively implement Commands like a RichTextBox
.
Can anyone please confirm this?
I can confirm that, WPF WebBrowser
control doesn't support WPF commands out-of-the-box. You'd need to implement a layer which handles WPF commands and translates them to the corresponding IHTMLDocument2::execCommand
commands. To do that, you could create a custon control (derived from UserControl
) and embed the WebBrowser
control inside it. You cannot derive from WebBrowser
directly as it's sealed
.
我不是WPF专家,但是我知道Webbrowser控件与应用程序中的真实浏览器相同,因此它仅呈现HTML,并且无法理解WPF或asp.net代码。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.