WPF 浏览器在那里,但不可见 [英] WPF Browser is there, but invisible

查看:25
本文介绍了WPF 浏览器在那里,但不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在一个非常简单的 WPF 应用程序中使用浏览器控件,看起来当浏览器正在加载我请求的页面(我可以将鼠标悬停在图像上并看到 ALT 标签)时,我实际上看不到还要别的吗:

这是应用程序的 XAML:

<Border Background="#50FFFFFF" CornerRadius="5" BorderThickness="2,0,2,2"填充=5 1 5 5"><网格><Grid.RowDefinitions><RowDefinition Height="自动"></RowDefinition><RowDefinition Height="自动"></RowDefinition><RowDefinition Height="自动"></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"背景="透明" FontSize="20" MouseLeftButtonDown="searchText_MouseLeftButtonDown"BorderBrush="透明"/><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"宽度="480" 高度="480" 边距="2 2 2 2" ></WebBrowser></网格></边框></窗口>

那么谁能帮我弄清楚为什么浏览器没有显示 Yahoo!主页就像我问的那样?当我在做的时候,我会承认这是我的第一个 WPF 应用程序,我很想听听任何关于如何摆脱 XAML 中的一般 noobie 坏处的一般指示.

谢谢.

解决方案

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

您需要设置 AllowsTransparency="False" :)

I am attempting to use the Browser control in a very simple WPF application, and it appears that while the browser is loading the page that I requested (I can mouseover images and see the ALT tags), I can't actually see anything else:

Here is the XAML for the app:

<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>

So can anyone help me figure out why the browser isn't showing the Yahoo! home page like I asked it to? And while I am at it, I'm going to own up to the fact that this is my first WPF app, and I'd love to hear any general pointers on how to get rid of general noobie badness in my XAML.

Thanks.

解决方案

Just a quick reply unfortunately, getting late...

You need to set AllowsTransparency="False" :)

这篇关于WPF 浏览器在那里,但不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆