tags:

views:

261

answers:

2

Given the following little snippet:

<Grid>
  <Frame Width="300" Height="300" Background="Blue"></Frame>
  <Frame Width="350" Height="350" Background="Red"></Frame>
</Grid>

as expected you don't get to see the blue frame (it being behind the red one).

However, if you include the source attribute to the blue frame:

<Grid>
  <Frame Width="300" Height="300" Background="Blue" Source="c:\test.htm"></Frame>
  <Frame Width="350" Height="350" Background="Red"></Frame>
</Grid>

it pops itself to the front.

Any idea why and can I prevent it?

thanks

A: 

I think the blue pops up in the second example, because of its updated or the rendering finished of the uielement when the file is loaded. Perhaps this works:

<Grid>
  <Frame Width="300" Height="300" Background="Blue" Source="c:\test.htm" Panel.ZIndex="0"></Frame>
  <Frame Width="350" Height="350" Background="Red" Panel.ZIndex="1"></Frame>
</Grid>
martin
+2  A: 

The Frame element with an external source uses in fact the classical IE COM component. Since it's not directly WPF, it doesn't participate in the WPF layout and must be "on top" of the WPF layer to be seen, and cannot be rotated or scaled. That's the same problem you have when using a HwndHost to host win32 content in WPF. See this MSDN page for more information.

There is no real workaround, but you can try to use WPF Chromium which use Chromium's engine to directly render web pages as a real WPF element.

Julien Lebosquain