1.MainPage.xaml

 <UserControl x:Class="SilverlightClient.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="" d:DesignHeight="">
<Grid x:Name="LayoutRoot">
<StackPanel>
<!--导航栏-->
<StackPanel Orientation="Horizontal" Background="WhiteSmoke">
<Button x:Name="myHTML" Content="HTML内容" FontSize=""/>
<Button x:Name="myFlash" Content="Flash" FontSize=""/>
<Button x:Name="myPDF" Content="PDF文档" FontSize=""/>
</StackPanel>
<Grid x:Name="Container"/>
</StackPanel>
</Grid>
</UserControl>

2.MainPage.xaml.cs

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Divelements.SilverlightTools; namespace SilverlightClient
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
//注册事件触发处理
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
this.myHTML.Click += new RoutedEventHandler(myHTML_Click);
this.myFlash.Click += new RoutedEventHandler(myFlash_Click);
this.myPDF.Click += new RoutedEventHandler(myPDF_Click);
} void MainPage_Loaded(object sender, RoutedEventArgs e)
{
GetRichContent("http://cn.bing.com", UriKind.Absolute);
} void myPDF_Click(object sender, RoutedEventArgs e)
{
GetRichContent("/test.pdf",UriKind.Relative);
} void myFlash_Click(object sender, RoutedEventArgs e)
{
GetRichContent("/clock.swf", UriKind.Relative);
} void myHTML_Click(object sender, RoutedEventArgs e)
{
GetRichContent("http://cn.bing.com", UriKind.Absolute);
} //获取Rich Content
void GetRichContent(string uri,UriKind uk)
{
Container.Children.Clear();
ControlHtmlHost chtml = new ControlHtmlHost();
HtmlHost hh = chtml.FindName("htmlHost") as HtmlHost;
hh.SourceUri = new Uri(uri, uk);
Container.Children.Add(chtml);
}
}
}

3.添加Divelements.SilverlightTools.dll文件

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

05-11 11:28