由于先前写过一文章是关于Silverlight 嵌入 HTML 网页 的文章,但用这些控件需开启windowless=true 模式,从而导致不能输入 textbox 不能输入中文,为了解决此问题,为Silverlight开发人员能够更好的在Silverlight 中嵌入网页,本人于是特制写了一个Silverlight 嵌入网页的控件以供广大程序员使用;
控件名称叫:WillisHtml
使用方法及参数说明:
属性:
1、 HtmlControlLeft: 距离左边的距离;
2、 HtmlControlTop :上边距离
3、HtmlControlId: 控件ID
4、NavigationUrl: HTML 网址 ,如http://www.cnblogs.com/waren168
示例如如下:
1、先把 WillisHtml.dll 下载到本地,然后添加引用到项目中;
2、后台代码 加入:
using Willis;
3、在前台XAML的 UserControl 中加入 以下代码;
xmlns:willishtml = " clr-namespace:Willis;assembly=WillisHtml "
然后在 Grid 中 引入
<willishtml:WillisHtml x:Name="willishtml" HtmlControlLeft="0" HtmlControlTop="0" NavigationUrl="http://www.cnblogs.com/waren168"></willishtml:WillisHtml>
完前台代码示例:
< UserControl x:Class = " SilverlightXchat.MainPage " xmlns = " http://schemas.microsoft.com/winfx/2006/xaml/presentation " xmlns:x = " http://schemas.microsoft.com/winfx/2006/xaml " xmlns:d = " http://schemas.microsoft.com/expression/blend/2008 " xmlns:mc = " http://schemas.openxmlformats.org/markup-compatibility/2006 " xmlns:willishtml = " clr-namespace:Willis;assembly=WillisHtml " xmlns:divtoolses = " clr-namespace:Divelements.SilverlightTools;assembly=Divelements.SilverlightTools " mc:Ignorable = " d " d:DesignHeight = " 300 " d:DesignWidth = " 400 " > < Grid x:Name = " LayoutRoot " Background = " Blue " ShowGridLines = " True " > < Grid.RowDefinitions > < RowDefinition ></ RowDefinition > </ Grid.RowDefinitions > < Grid.ColumnDefinitions > < ColumnDefinition ></ ColumnDefinition > </ Grid.ColumnDefinitions > < willishtml:WillisHtml x:Name = " willishtml " HtmlControlLeft = " 0 " HtmlControlTop = " 0 " NavigationUrl = " http://www.cnblogs.com/waren168 " ></ willishtml:WillisHtml > </ Grid > </ UserControl >
4、到目前为此大功造成了,你想嵌入什么网页只要把地址给 NavigationUrl 就可以轻松搞定了;
5、 WillisHtml 下载地址:点击载下
6、实例下载:点击下载