WPF and HTML
Unlike ActiveX or Windows Forms controls, WPF elements cannot be hosted directly on an HTML page (i.e., there's nothing to support this kind of thing in HTML), as shown in Example B-11.
Example B-11. WPF controls can't be hosted directly in HTML
<html>
<body>
<h1>WPF doesn't support anything like this!</h1>
<object
id="wpfctrl"
classid="wpfctrl.dll#wpfctrl.MyWpfControl"
width="100"
height="100">
</object>
</body>
</html>You can get around this issue again by hosting a WPF control on a custom Windows Forms User Control. Or, if you've got a WPF XBAP as described in Chapter 11, you can host it as a frame as shown in Example B-12.
Example B-12. WPF XBAP hosted in an HTML iframe
<html>
<body>
<h1>WPF supports this!</h1>
<iframe src="MyWpfApp.xbap"></iframe>
</body>
</html>The downside of this approach is that the WPF application cannot provide any programmatic interface (e.g., properties, methods, or events) to the surrounding HTML, like an ActiveX control would.
To go the other way and host HTML inside WPF is a matter of bringing either the COM or the Windows Forms Web Browser control into your WPF app and feeding it HTML. Or, if the HTML is available via a URL, you can navigate to it on a navigation host, as Example B-13 illustrates.
Example B-13. Navigating to an URL using a WPF navigation host
<Page ...>
<Grid>
<TextBlock>
Check out
<Hyperlink
NavigateUri="http://sellsbrothers.com">sellsbrothers.com</Hyperlink>.
</TextBlock>
</Grid>
</Page>Because the link references ...