当前位置:编程学习 > asp >>

WPF——WebBroswer无法显示问题

view plaincopyprint?
 
在WPF中Window里面放置WebBroswer控件居然无法显示:
源代码如下:
[html]
<Window x:Class="MutilScreenDemo.MainWindow" 
        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" 
        Title="MainWindow" 
        AllowsTransparency="True" 
        Background="Black" 
        BorderBrush="Transparent" 
        BorderThickness="0" 
        d:DesignHeight="348" 
        d:DesignWidth="892" 
        Loaded="Window_Loaded" 
        ResizeMode="NoResize" 
        WindowStyle="None" 
        mc:Ignorable="d"> 
 
    <Grid x:Name="layoutRoot"> 
        <Grid.RowDefinitions> 
            <RowDefinition Height="100" /> 
            <RowDefinition Height="*" /> 
        </Grid.RowDefinitions> 
        <Rectangle Height="2" 
                   VerticalAlignment="Bottom" 
                   Fill="White" /> 
        <TextBlock Name="txtShow" 
                   Grid.Row="0" 
                   HorizontalAlignment="Left" 
                   VerticalAlignment="Center" 
                   FontSize="50" 
                   FontWeight="Bold" 
                   Foreground="Red" 
                   Text="Hello World!" /> 
        <StackPanel Grid.Row="0" 
                    HorizontalAlignment="Right" 
                    VerticalAlignment="Center" 
                    Orientation="Horizontal"> 
            <Button Name="button1" 
                    Margin="5" 
                    HorizontalAlignment="Right" 
                    VerticalAlignment="Top" 
                    Click="button1_Click" 
                    Content="Get Screen Info" 
                    Padding="20" /> 
            <Button Name="btnShutdown" 
                    Margin="5" 
                    HorizontalAlignment="Right" 
                    VerticalAlignment="Top" 
                    Click="btnShutdown_Click" 
                    Content="ShutDown App" 
                    Padding="20" /> 
        </StackPanel> 
[html]
 
[html]
    <WebBrowser Name="broswer" 
                Grid.Row="1"/> 
</Grid> 
/Window> 

显示效果:


经过折腾和尝试,问题出在Window里面的AllowsTransparency属性,WebBroswer控件显示和AllowsTransparency为True时产生冲突。
去掉AllowsTransparency后显示效果如下:


但是具体问什么会这样,我没搞清楚。希望有大神指点一二!!

补充:Web开发 , ASP.Net ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,