• silverlight中嵌入html、swf、pdf


    使用HtmlHost小组件就方便多了

    网站:http://www.divelements.co.uk/silverlight/tools.aspx

    下载:http://www.divelements.co.uk/silverlight/SilverlightTools.1.0.2.zip

    1、基本特性

    组件所在命名空间:

    Divelements.SilverlightTools

    组件常用属性:

    SourceUri:显示在该组件中的内容的URI。

    SourceHtml:用该组件显示的超文本内容。

    Document:显示在该组件中的内容的HTML。

    组件常用事件:

    DocumentReady:当在该组件中的内容的HTML加载完毕后触发该事件。

    注:该组件在windowless下才能正常工作

     <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/testMap.xap"/>
              <param name="onError" value="onSilverlightError" />
              <param name="background" value="white" />
              <param name="minRuntimeVersion" value="4.0.60310.0" />
              <param name="autoUpgrade" value="true" />
              <param name="windowless" value="true" />
              <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.60310.0" style="text-decoration:none">
                   <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="获取 Microsoft Silverlight" style="border-style:none"/>
              </a>
            </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;0px;border:0px"></iframe>
            
            </div>

    新建一个controlHtmlHost.xaml页面

    <navigation:Page x:Class="testMap.ControlHtmlHost"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
               mc:Ignorable="d"
               xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
               d:DesignWidth="640" d:DesignHeight="480"
               Title="ControlHtmlHost Page" xmlns:divtools="clr-namespace:Divelements.SilverlightTools;assembly=Divelements.SilverlightTools">
        <Grid x:Name="LayoutRoot">
            <divtools:HtmlHost Name="htmlHost" />
        </Grid>
    </navigation:Page>

    MainPage.xaml页面

    <UserControl x:Class="testMap.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" xmlns:my="clr-namespace:Drawsee.Sl.Kernel.Controls;assembly=Drawsee.Sl.Kernel" xmlns:my1="clr-namespace:Drawsee.Sl.AppBase.Database.UI;assembly=Drawsee.Sl.AppBase" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" Height="535" Width="783" xmlns:divtools="clr-namespace:Divelements.SilverlightTools;assembly=Divelements.SilverlightTools">

        <Grid x:Name="LayoutRoot" Background="White">
            <Grid Height="316" HorizontalAlignment="Left" Margin="173,39,0,0" Name="Container" VerticalAlignment="Top" Width="600">
                <divtools:HtmlHost HorizontalAlignment="Left" Margin="339,131,0,0" Name="htmlHost1" VerticalAlignment="Top" />
            </Grid>
            <Button Content="btnHtml" Height="23" HorizontalAlignment="Left" Margin="696,500,0,0" Name="btnLoad" VerticalAlignment="Top" Width="75" Click="btnLoad_Click" />
        </Grid>
    </UserControl>

    MainPage.xaml.cs

       private void btnLoad_Click(object sender, RoutedEventArgs e)
            {
                GetRichContent("index.htm", UriKind.Relative); //""内可以写swf、html和pdf文件
            }

            private void GetRichContent(string uri, UriKind uriKind)
            {
                Content.Children.Clear();
                ControlHtmlHost chtml = new ControlHtmlHost();
                HtmlHost hh = chtml.FindName("htmlHost") as HtmlHost;
                hh.SourceUri = new Uri(uri, uriKind);
                Content.Children.Add(chtml);
            }

  • 相关阅读:
    洛谷4451 整数的lqp拆分(生成函数)
    CF1137C Museums Tour(Tarjan,强连通分量)
    CF932E Team Work(第二类斯特林数)
    CF1131F Asya And Kittens(Kruskal重构树,启发式合并)
    CF1131E String Multiplication(???)
    CF438E The Child and Binary Tree(生成函数,NTT)
    [HAOI2015]按位或(min-max容斥,FWT,FMT)
    【noi 2.6_9281】技能树(DP)
    【noi 2.6_9280】&【bzoj 1089】严格n元树(DP+高精度+重载运算符)
    【noi 2.6_9277】Logs Stacking堆木头(DP)
  • 原文地址:https://www.cnblogs.com/ZJ199012/p/2423324.html
Copyright © 2020-2023  润新知