在 Silverlight 中加载 HTML

作者:源码世界时间:2014-03-18分类:WPF/SliverLight评论:0浏览:6241

1. [代码]Create one XAML page     跳至 [1]
<UserControl x:Class="HtmlExample.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:HtmlExample="clr-namespace:HtmlExample" mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <Style TargetType="TextBlock" x:Key="StyleText">
            <Setter Property="FontFamily" Value="Lucida Sans Unicode"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="FontWeight" Value="Bold"/>
         </Style>
     </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                <GradientStop Offset="0" Color="#800000FF"/>
                <GradientStop Offset="1" Color="#80FFFFFF"/>
            </LinearGradientBrush>
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>            
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <TextBlock Style="{StaticResource StyleText}" Text="Url:" Grid.Column="0" Margin="5"/>
            <TextBox TextAlignment="Left" VerticalAlignment="Center" Text="http://www.jeremylikness.com/" x:Name="txtUrl" HorizontalAlignment="Stretch" Margin="5" Grid.Column="1"/>
            <Button Click="Button_Click" HorizontalAlignment="Center" Grid.Column="2" Margin="5"> 
                <Button.Content>
                    <TextBlock Style="{StaticResource StyleText}" Text="Load" Margin="5"/>
                </Button.Content>
            </Button>
        </Grid>
        <Border CornerRadius="20" Margin="5" Grid.Row="1">
            <Border.Background>
                <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                    <GradientStop Offset="0" Color="White"/>
                    <GradientStop Offset="1" Color="Blue"/>
                </LinearGradientBrush>
            </Border.Background>
        </Border>
        <HtmlExample:HtmlHost Grid.Row="1"
                              x:Name="HtmlHostCtrl"
                              Margin="40"
                              HorizontalAlignment="Stretch"
                              VerticalAlignment="Stretch"
                              HostDiv="htmlHost"
                              Url="http://localhost/TestWebApplication/default.aspx"/>
    </Grid>
</UserControl>

如果您没有找到适合你的解决方案,请联系我们寻求帮助支付鼓励

标签:WPF/SliverLight  
返回顶部
分享按钮