我怎样才能把web浏览器显示的背后我的控制?我的、浏览器、web

2023-09-03 07:09:31 作者:番茄炒蛋

我试图让WebBrowser控件顶部的菜单中,因此当用户选择它,它会告诉web浏览器去centain页。

I am trying to make a menu on top of WebBrowser control, so when user select it, it will tell the WebBrowser to go centain page.

所以,我不喜欢的东西:

So I did something like:

<Grid x:Name="Root">
    <WebBrowser Name="_WebBrowser" Source="http://google.ca" Grid.Column="0" Grid.Row="0"></WebBrowser>    
    <Expander Name="expander1" HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="250" ExpandDirection="Right" IsExpanded="True" Grid.Column="0" Grid.Row="0">

据我所知,最后确定应控制在上面......

Far as I know, the last define control should be on top...

但奇怪的web​​浏览器将始终显示在顶部....,它涵盖了我的扩展(菜单)。 我试图把web浏览器里面Carvas甚至按钮大声笑,但它仍然显示在顶部的web浏览器....

But strange, the WebBrowser will always display on top....and it covers my Expander (menu). I tried to put WebBrowser inside a Carvas or even Button lol But the WebBrowser it is still display on the top....

我希望这不是在.NET 3.5中的错误......

I hope this is not a bug in .NET 3.5.....

推荐答案

简单的回答是,这是WPF的限制。

The short answer is this is a limitation of WPF.

web浏览器控制仅仅是Windows的COM组件,它有自己的窗口句柄周围的托管包装。出于这个原因,你不能在它上面绘制。

The WebBrowser control is simply a managed wrapper around the Windows COM component, which has its own window handle. For this reason, you're not able to draw over it.

更多细节: WPF 3.5 WebBrowser控件和zIndex的