zoukankan      html  css  js  c++  java
  • Silverlight中嵌套html、swf、pdf

    1.MainPage.xaml

     1 <UserControl x:Class="SilverlightClient.MainPage"
     2     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     3     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     4     xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"        
     5     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     6     mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
     7   <Grid x:Name="LayoutRoot">
     8         <StackPanel>
     9             <!--导航栏-->
    10             <StackPanel Orientation="Horizontal" Background="WhiteSmoke">
    11                 <Button x:Name="myHTML" Content="HTML内容" FontSize="14"/>
    12                 <Button x:Name="myFlash" Content="Flash" FontSize="14"/>
    13                 <Button x:Name="myPDF" Content="PDF文档" FontSize="14"/>
    14             </StackPanel>
    15             <Grid x:Name="Container"/>
    16         </StackPanel>
    17     </Grid>
    18 </UserControl>
    View Code

    2.MainPage.xaml.cs

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Net;
     5 using System.Windows;
     6 using System.Windows.Controls;
     7 using System.Windows.Documents;
     8 using System.Windows.Input;
     9 using System.Windows.Media;
    10 using System.Windows.Media.Animation;
    11 using System.Windows.Shapes;
    12 using Divelements.SilverlightTools;
    13 
    14 namespace SilverlightClient
    15 {
    16     public partial class MainPage : UserControl
    17     {
    18         public MainPage()
    19         {
    20             InitializeComponent();
    21             //注册事件触发处理
    22             this.Loaded += new RoutedEventHandler(MainPage_Loaded);
    23             this.myHTML.Click += new RoutedEventHandler(myHTML_Click);
    24             this.myFlash.Click += new RoutedEventHandler(myFlash_Click);
    25             this.myPDF.Click += new RoutedEventHandler(myPDF_Click);
    26         }
    27 
    28         void MainPage_Loaded(object sender, RoutedEventArgs e)
    29         {
    30             GetRichContent("http://cn.bing.com", UriKind.Absolute);
    31         }
    32 
    33         void myPDF_Click(object sender, RoutedEventArgs e)
    34         {
    35             GetRichContent("/test.pdf",UriKind.Relative);
    36         }
    37 
    38         void myFlash_Click(object sender, RoutedEventArgs e)
    39         {
    40             GetRichContent("/clock.swf", UriKind.Relative);
    41         }
    42 
    43         void myHTML_Click(object sender, RoutedEventArgs e)
    44         {
    45             GetRichContent("http://cn.bing.com", UriKind.Absolute);
    46         }
    47 
    48         //获取Rich Content
    49         void GetRichContent(string uri,UriKind uk)
    50         {
    51             Container.Children.Clear();
    52             ControlHtmlHost chtml = new ControlHtmlHost();
    53             HtmlHost hh = chtml.FindName("htmlHost") as HtmlHost;
    54             hh.SourceUri = new Uri(uri, uk);
    55             Container.Children.Add(chtml);
    56         }
    57     }
    58 }
    View Code

    3.添加Divelements.SilverlightTools.dll文件

    4.在服务端添加相应的访问文件

  • 相关阅读:
    java连接常见数据库的连接字符串
    一个用来自动管理大容量表的Sql脚本
    Ibatis2.0使用说明(一)——入门实例篇
    态度决定你的人生高度
    jboss配置入门(二) -JBOSS3.2.3/3.2.6部署及配置修改
    如何在一个工程里面实现不同的功能打入不同的日志文件中【log4net】
    Xsl实践总结(一)
    Xsl实践总结(三)-介绍一款开发XSL不错的IDE(Stylus)
    Xsl实践总结(二)
    教你节省时间 让你个人效率翻三倍
  • 原文地址:https://www.cnblogs.com/zxbzl/p/3865760.html
Copyright © 2011-2022 走看看