Divelements
Because every action starts with the presentation layer
Silverlight
  Home Products Downloads Store Support Corporate  
Free Silverlight Controls
Home / Silverlight

This is an ongoing effort to provide various simple controls and components of a production quality for free, for general use. Anybody can use these tools, whether in free or commercial software. At the moment we only have one control in the toolset, but we hope to expand it shortly. If you have any ideas (simple tools only please) feel free to contact us about them.

Note that there is no installer for these tools. Just extract the archive into a directory of your choice, read the license and use the choose items command in the Visual Studio toolbox to add the controls to your toolbox, if desired.

Download Silverlight Tools 1.0.2

HtmlHost

Many people have a need to display richly-formatted content in Silverlight, and at present the options for doing so are very limited. There is no document model or rich text facilities, and certainly no support for embedding HTML. This control allows you to embed HTML anywhere in a Silverlight application by simply specifying raw HTML to display or, if you prefer, the URL to a web page.

The control works by asking the host browser to create a DIV tag in which to display the HTML, and positioning it cleverly to match up with the Silverlight layout system. You should find that this "just works" as the HtmlHost control is dynamically moved or shown (on a tab page, for example) or even if the Silverlight plugin itself is moved. You must be using the Silverlight plugin in windowless mode to use this control.

This is how you use the control to host live or external web content.

<Grid x:Name="LayoutRoot" Background="White"> 
    <Border Margin="30"> 
        <!-- Embed HTML within the page --> 
        <divtools:HtmlHost Name="htmlHost" SourceUri="http://www.google.com" /> 
    </Border> 
</Grid>

And this is how you create HTML on the fly.

private void Button_Click(object sender, RoutedEventArgs e) 
{ 
    // Populate the control with html 
    StringBuilder html = new StringBuilder(); 
    html.AppendLine("<h1>Heading</h1>"); 
    html.AppendLine("<p>This is a paragraph <span style='color: red'>using</span> CSS <strong>formatting</strong>.</p>"); 
    html.AppendLine("<ul><li>List Item 1</li><li>List Item 2</li></ul>"); 

    htmlHost.SourceHtml = html.ToString(); 
}
Copyright © 2003 - 2009 Divelements Limited       About | Contact | Privacy