在Silverlight里面嵌入HTML/ASPX/URL/Document/SVG等

来源:互联网 发布:青山软件造价 编辑:程序博客网 时间:2024/06/06 00:33
本文来自:银光中国 http://www.silverlightchina.net/html/tips/2011/0512/7602.html
第一步:下载组件 Download Silverlight Tools 1.0.2 解压缩,将dll文件放到合适的位置。 第二步:在工具栏右键 [Choose Items] 用[Browse]找到Divelements.SilverlightTools.dll,添加 第三步:将组件拖到silverlight编辑页面中,这时自动添加了对命名空间的引用 xmlns:divtools= clr-namespace:Divelements.SilverlightT
  

  第一步:下载组件Download Silverlight Tools 1.0.2解压缩,将dll文件放到合适的位置。

  第二步:在工具栏右键 [Choose Items] 用[Browse]找到Divelements.SilverlightTools.dll,添加

  第三步:将组件拖到silverlight编辑页面中,这时自动添加了对命名空间的引用

xmlns:divtools="clr-namespace:Divelements.SilverlightTools;assembly=Divelements.SilverlightTools"

 

  第四步:在要嵌入的位置加入HtmlHost组件,例如:

<divtools:HtmlHost Name="htmlHost" SourceUri="http://localhost:2883/enbedded.aspx" />

 

  第五步:最后不要忘了在silverlight 的宿主页,加上 <param name="Windowless" value ="true" />,否则会弹出窗口报错“You must be using the Silverlight plugin in windowless mode to use this control.”,事例如下:

//以下来自silverlight自动生成的TestPage.aspx

<body>    <form id="form1" runat="server"style="height:100%">    <div id="silverlightControlHost">    <object data="data:application/x-silverlight-2," type="application/x-silverlight-2"width="100%" height="100%">          <param name="source" value="ClientBin/ECSDashboard.xap"/>           ……          <param name="autoUpgrade" value="true" />          <param name="Windowless" value ="true" />     </object>    <div>    </form></body>



----------------------------------------------

  直接加入Html内容,实例

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(); }


 

 

原创粉丝点击