Silverlight’s HtmlBrush is an alternative to the WebBrowser control for displaying HTML content in Silverlight app. There are two primary differences between the HtmlBrush and WebBrowser controls :
- WebBrowser can display “live” content, whereas the HtmlBrush only display static html content
- HtmlBrush can have transforms applied to it, so for visual effects this is the control of choice.
The below sample shows how to paint a simple rectangle with the HtmlBrush:
You can render HTML content with HtmlBrush, too. The following XAML snippet ‘paints’ a Rectangle with an HTML page.
<WebBrowser Name=”demoWB” Source=”/silverlightace.htm” />
<Rectangle Canvas.Left=”1″ Canvas.Top=”20″ Height=”100″ Width=”100″>
<Rectangle.Fill>
<HtmlBrush SourceName=”demoWB” x:Name=”demoBrush” />
</Rectangle.Fill>
</Rectangle>