3

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

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

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

King Chan
  • 4,212
  • 10
  • 46
  • 78
  • You need to define grid rows and columns and place the controls in the appropriate row and column. – paparazzo Jan 27 '12 at 20:46
  • @BalamBalam Even if I define the row and column, it still has the same issue. When I replace WebBrowser with other Control in this code, it just work fine. – King Chan Jan 27 '12 at 21:04
  • 2
    An alternative WPF web browser control is Awesomium (http://awesomium.com/). Is this of interest to you? – Luke Woodward Jan 27 '12 at 22:50
  • @LukeWoodward Sounds awesome~ I am going it out when I got office on monday! Thanks! Just got to pray it support .NET 3.5.... – King Chan Jan 28 '12 at 01:09
  • Sadly, it seems Awesomium only supports .NET 4: http://support.awesomium.com/discussions/questions/549-net-35-version. – Luke Woodward Jan 28 '12 at 22:22

1 Answers1

4

The short answer is this is a limitation of WPF.

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.

More details: WPF 3.5 WebBrowser control and ZIndex

Community
  • 1
  • 1
Mike Christensen
  • 88,082
  • 50
  • 208
  • 326