WPF浏览器在那里,但不可见

Ada*_*and 15 wpf wpf-controls

我试图在一个非常简单的WPF应用程序中使用浏览器控件,看来当浏览器加载我请求的页面时(我可以鼠标悬停图像并看到ALT标签),我实际上看不到任何其他内容: 替代文字

这是应用程序的XAML:

<Window x:Class="SmokeyBox2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="SmokeyBox" Height="120" Width="510" ShowInTaskbar="False"
        SizeToContent="WidthAndHeight" WindowStyle="None" AllowsTransparency="True"
        MouseLeftButtonDown="Window_MouseLeftButtonDown">
    <Border Background="#50FFFFFF" CornerRadius="5" BorderThickness="2,0,2,2"
            Padding="5 1 5 5">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Label Grid.Row="0" Grid.Column="0" Background="Transparent"  Content="SmokeyBox" 
                   MouseLeftButtonDown="Label_MouseLeftButtonDown" />
            <TextBox Grid.Row="1" Grid.Column="0" Name="searchText" Width="450" FontFamily="Arial" Foreground="DarkGray"
                     Background="Transparent" FontSize="20" MouseLeftButtonDown="searchText_MouseLeftButtonDown"
                     BorderBrush="Transparent" />
            <Expander Grid.Row="1" Grid.Column="1" Padding="2 3 0 0 " Expanded="Expander_Expanded"
                      Collapsed="Expander_Collapsed" />
            <WebBrowser Grid.Row="2" Grid.Column="0" x:Name="browser" Visibility="Visible"
                        Width="480" Height="480" Margin="2 2 2 2" ></WebBrowser>
        </Grid>
    </Border>
</Window>
Run Code Online (Sandbox Code Playgroud)

所以任何人都可以帮我弄清楚为什么浏览器没有显示Yahoo! 像我问的主页?虽然我在这里,但我将完全承认这是我的第一个WPF应用程序,我很想听听有关如何摆脱我的XAML中的一般noobie不良的一般指示.

谢谢.

Tim*_*oyd 18

不幸的是,快速回复,迟到了......

你需要设置AllowTransparency ="False":)

  • 为什么窗口透明度会影响网页浏览器控件? (3认同)

小智 5

WPF WebBrowser不能与allowsTransparency ="True"一起使用.