1.xaml
<UserControl xmlns:SilverlightClient="clr-namespace:SilverlightClient" 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"
xmlns:SlInpu="clr-namespace:Sl.Input;assembly=Sl.Input"
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 Grid.Row="" x:Name="contentLayout2" Visibility="Visible">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border x:Name="borHtmlrb" HorizontalAlignment="Stretch" Grid.Row="" Grid.Column="" Background="Red">
<SilverlightClient:ControlHtmlHost x:Name="ccc"/>
</Border>
<Border Grid.Row="" Grid.Column="" Background="Blue">
<ScrollViewer Margin="0,5,5,5">
<Grid Grid.Row="" Grid.Column="" Margin="0,5,5,5">
<Grid.RowDefinitions>
<RowDefinition Height=""/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="">
<!--<TextBox Width="" Height=""/>-->
<!--<SlInpu:SLInput x:Name="mytxt" Width="" Height="" Foreground="Red" FontSize="" ></SlInpu:SLInput>-->
<SlInpu:SLInput x:Name="mytxt1" Width="" Height="" Foreground="Red" FontSize="" ></SlInpu:SLInput>
</StackPanel>
<StackPanel Grid.Row="" HorizontalAlignment="Center" Margin="0,15,0,5">
<TextBlock x:Name="txtTimeThree" FontSize="" FontFamily="SimSun" Text=""/>
<TextBlock x:Name="txtTimeFWThree" FontSize="" FontFamily="SimSun" Text=""/>
</StackPanel>
<Border Grid.Row="" Margin="">
<Button Content="dddd" Width="" Height=""/>
</Border>
<StackPanel Grid.Row="" HorizontalAlignment="Center" Margin="0,15,0,5">
<TextBlock x:Name="txtTimeSix" FontSize="" FontFamily="SimSun" Text=""/>
<TextBlock x:Name="txtTimeFWSix" FontSize="" FontFamily="SimSun" Text=""/>
</StackPanel>
<Border Grid.Row="" Margin="">
<Button Content="dddd" Width="" Height=""/>
</Border>
</Grid>
</ScrollViewer>
</Border>
<Border x:Name="borHtmlyb" Grid.Row="" Grid.Column="" Background="Red">
<SilverlightClient:ControlHtmlHost x:Name="aaa" />
</Border>
<Border x:Name="borHtmlxb" Grid.Row="" Grid.Column="" Background="Red">
<SilverlightClient:ControlHtmlHost x:Name="bbb" />
</Border>
</Grid>
</StackPanel> </Grid>
</UserControl>
2.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);
//InitHtml();
//MessageBox.Show(mytxt.Text);
} void myFlash_Click(object sender, RoutedEventArgs e)
{
//GetRichContent("/clock.swf", UriKind.Relative);
} void myHTML_Click(object sender, RoutedEventArgs e)
{
GetRichContent(aaa, "/YB.HTM", UriKind.Relative);
GetRichContent(bbb, "/YB.HTM", UriKind.Relative);
GetRichContent(ccc, "/XB.HTM", UriKind.Relative);
}
private void InitHtml()
{
GetRichContent(borHtmlrb, "/DQ.HTM", UriKind.Relative);
GetRichContent(borHtmlyb, "/YB.HTM", UriKind.Relative);
GetRichContent(borHtmlxb, "/XB.HTM", UriKind.Relative);
}
private void GetRichContent(Border name, string uri, UriKind uk)
{
ControlHtmlHost chtml = new ControlHtmlHost();
HtmlHost hh = chtml.FindName("htmlHost") as HtmlHost;
hh.SourceUri = new Uri(uri, uk);
name.Child = chtml;
}
//获取Rich Content
void GetRichContent(ControlHtmlHost chtml, string uri, UriKind uk)
{
HtmlHost hh = chtml.FindName("htmlHost") as HtmlHost;
hh.SourceUri = new Uri(uri, uk); }
}
}
3.添加引用Divelements.SilverlightTools.dll
4.设置启动页面 <param name="windowless" value="true" />
以上是设置silverlight嵌套html文件
5.添加Sl.Input.dll引用
6.在xaml里添加<SlInpu:SLInput x:Name="mytxt1" Width="220" Height="150" Foreground="Red" FontSize="18" ></SlInpu:SLInput>
7.在百度网盘里搜索slInput.rar
8.有需要类库的朋友,请给我留言。。。。