码迷,mamicode.com
首页 > Web开发 > 详细

Silverlight中嵌套html、swf、pdf

时间:2014-07-24 21:19:03      阅读:285      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   os   文件   io   

1.MainPage.xaml

bubuko.com,布布扣
 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

bubuko.com,布布扣
 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.在服务端添加相应的访问文件

Silverlight中嵌套html、swf、pdf,布布扣,bubuko.com

Silverlight中嵌套html、swf、pdf

标签:des   style   blog   http   color   os   文件   io   

原文地址:http://www.cnblogs.com/zxbzl/p/3865760.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!