zoukankan      html  css  js  c++  java
  • silverlight嵌套html不能输入中文问题

    1.xaml

     1 <UserControl xmlns:SilverlightClient="clr-namespace:SilverlightClient"  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              xmlns:SlInpu="clr-namespace:Sl.Input;assembly=Sl.Input"
     7     mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="800">
     8     <Grid x:Name="LayoutRoot">
     9         <StackPanel>
    10             <!--导航栏-->
    11             <StackPanel Orientation="Horizontal" Background="WhiteSmoke">
    12                 <Button x:Name="myHTML" Content="HTML内容" FontSize="14"/>
    13                 <Button x:Name="myFlash" Content="Flash" FontSize="14"/>
    14                 <Button x:Name="myPDF" Content="PDF文档" FontSize="14"/>
    15             </StackPanel>
    16             <Grid Grid.Row="1" x:Name="contentLayout2" Visibility="Visible">
    17                 <Grid.RowDefinitions>
    18                     <RowDefinition/>
    19                     <RowDefinition/>
    20                 </Grid.RowDefinitions>
    21                 <Grid.ColumnDefinitions>
    22                     <ColumnDefinition/>
    23                     <ColumnDefinition/>
    24                 </Grid.ColumnDefinitions>
    25                 <Border x:Name="borHtmlrb" HorizontalAlignment="Stretch" Grid.Row="0" Grid.Column="0" Background="Red">
    26                     <SilverlightClient:ControlHtmlHost x:Name="ccc"/>
    27                 </Border>
    28                 <Border Grid.Row="0" Grid.Column="1" Background="Blue">
    29                     <ScrollViewer Margin="0,5,5,5">
    30                         <Grid Grid.Row="0" Grid.Column="1" Margin="0,5,5,5">
    31                             <Grid.RowDefinitions>
    32                                 <RowDefinition Height="28"/>
    33                                 <RowDefinition/>
    34                                 <RowDefinition/>
    35                                 <RowDefinition/>
    36                                 <RowDefinition/>
    37                             </Grid.RowDefinitions>
    38                             <StackPanel Grid.Row="0">
    39                                 <!--<TextBox Width="120" Height="30"/>-->
    40                                 <!--<SlInpu:SLInput x:Name="mytxt" Width="220" Height="50" Foreground="Red" FontSize="18" ></SlInpu:SLInput>-->
    41                                 <SlInpu:SLInput x:Name="mytxt1" Width="220" Height="150" Foreground="Red" FontSize="18" ></SlInpu:SLInput>
    42                             </StackPanel>
    43                             <StackPanel Grid.Row="1" HorizontalAlignment="Center" Margin="0,15,0,5">
    44                                 <TextBlock x:Name="txtTimeThree" FontSize="14" FontFamily="SimSun" Text=""/>
    45                                 <TextBlock x:Name="txtTimeFWThree" FontSize="14" FontFamily="SimSun" Text=""/>
    46                             </StackPanel>
    47                             <Border Grid.Row="2"  Margin="5">
    48                                 <Button Content="dddd" Width="120" Height="30"/>
    49                             </Border>
    50                             <StackPanel Grid.Row="3" HorizontalAlignment="Center" Margin="0,15,0,5">
    51                                 <TextBlock x:Name="txtTimeSix" FontSize="14" FontFamily="SimSun" Text=""/>
    52                                 <TextBlock x:Name="txtTimeFWSix" FontSize="14" FontFamily="SimSun" Text=""/>
    53                             </StackPanel>
    54                             <Border Grid.Row="4"  Margin="5">
    55                                 <Button Content="dddd" Width="120" Height="30"/>
    56                             </Border>
    57                         </Grid>
    58                     </ScrollViewer>
    59                 </Border>
    60                 <Border x:Name="borHtmlyb" Grid.Row="1" Grid.Column="0" Background="Red">
    61                     <SilverlightClient:ControlHtmlHost x:Name="aaa" />
    62                 </Border>
    63                 <Border x:Name="borHtmlxb" Grid.Row="1" Grid.Column="1" Background="Red">
    64                     <SilverlightClient:ControlHtmlHost x:Name="bbb" />
    65                 </Border>
    66             </Grid>
    67         </StackPanel>
    68 
    69     </Grid>
    70 </UserControl>
    View Code

    2.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 
    15 namespace SilverlightClient
    16 {
    17     public partial class MainPage : UserControl
    18     {
    19         public MainPage()
    20         {
    21             InitializeComponent();
    22             //注册事件触发处理
    23             this.Loaded += new RoutedEventHandler(MainPage_Loaded);
    24             this.myHTML.Click += new RoutedEventHandler(myHTML_Click);
    25             this.myFlash.Click += new RoutedEventHandler(myFlash_Click);
    26             this.myPDF.Click += new RoutedEventHandler(myPDF_Click);
    27         }
    28 
    29         void MainPage_Loaded(object sender, RoutedEventArgs e)
    30         {
    31             //GetRichContent("http://cn.bing.com", UriKind.Absolute);
    32         }
    33 
    34         void myPDF_Click(object sender, RoutedEventArgs e)
    35         {
    36             //GetRichContent("/test.pdf",UriKind.Relative);
    37             //InitHtml();
    38             //MessageBox.Show(mytxt.Text);
    39         }
    40 
    41         void myFlash_Click(object sender, RoutedEventArgs e)
    42         {
    43             //GetRichContent("/clock.swf", UriKind.Relative);
    44         }
    45 
    46         void myHTML_Click(object sender, RoutedEventArgs e)
    47         {
    48             GetRichContent(aaa, "/YB.HTM", UriKind.Relative);
    49             GetRichContent(bbb, "/YB.HTM", UriKind.Relative);
    50             GetRichContent(ccc, "/XB.HTM", UriKind.Relative);
    51         }
    52         private void InitHtml()
    53         {
    54             GetRichContent(borHtmlrb, "/DQ.HTM", UriKind.Relative);
    55             GetRichContent(borHtmlyb, "/YB.HTM", UriKind.Relative);
    56             GetRichContent(borHtmlxb, "/XB.HTM", UriKind.Relative);
    57         }
    58         private void GetRichContent(Border name, string uri, UriKind uk)
    59         {
    60             ControlHtmlHost chtml = new ControlHtmlHost();
    61             HtmlHost hh = chtml.FindName("htmlHost") as HtmlHost;
    62             hh.SourceUri = new Uri(uri, uk);
    63             name.Child = chtml;
    64         }
    65         //获取Rich Content
    66         void GetRichContent(ControlHtmlHost chtml, string uri, UriKind uk)
    67         {
    68             HtmlHost hh = chtml.FindName("htmlHost") as HtmlHost;
    69             hh.SourceUri = new Uri(uri, uk);
    70 
    71         }
    72     }
    73 }
    View Code

    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.有需要类库的朋友,请给我留言。。。。

  • 相关阅读:
    PHP常量
    jquery中的几种常用总结
    jquery中的ajax
    常用的jquery一些总结
    js验证手机号邮箱号用户名
    PHP优化杂烩
    一个php开发的用于路由器的小功能
    HTML <form>
    window.open
    try&catch
  • 原文地址:https://www.cnblogs.com/zxbzl/p/4169476.html
Copyright © 2011-2022 走看看