• 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 设计的七大原则
    电脑开机一支黑屏 ,只有鼠标
    oracle 创建表空间 、用户 、赋权、建表
    input 标签禁止输入
    input框限制只能输入正整数、字母、小数、汉字
    LINUX 解压文件
    LINUX vim 修改文件 退出
    layui table表格字段过长,展示不完整时,鼠标放到上面展示完整信息
    全网最全JS正则表达式 校验数字
    《学习笔记》基於NOPI開發 ExeclHelper工具類
  • 原文地址:https://www.cnblogs.com/zxbzl/p/3865760.html
Copyright © 2020-2023  润新知