Reputation: 37633
I want to put over WPF WebBrowser some UIElement
(opacity = 0) ie and catch all click events via this overplaced UIElement
.
Is it possible to do?
This code doesn't work...
<Canvas Name="cnsMain">
<WebBrowser x:Name="MainBrowser" Visibility="Visible" Panel.ZIndex="0" />
<Canvas Panel.ZIndex="100" Opacity="0.01"></Canvas>
</Canvas>
Thanks!
Upvotes: 2
Views: 2902
Reputation: 25623
This can be done in .NET 4.5. It requires setting the following properties on your WebBrowser
control before it is ever rendered:
IsRedirected = true
CompositionMode = System.Windows.Interop.CompositionMode.Full
This will enable hwnd redirection, allowing the normal top-level hwnd used for rendering to be redirected to a WPF surface that can play nice with other elements in your tree.
EDIT: It would seem this feature was yanked out of .NET 4.5 prior to release. My apologies if I gave anyone false hope. Thanks to @JoeDaley for pointing out my error.
Upvotes: 1
Reputation: 21251
No, the WPF Webbrowser is just the standard browser control in a WPF wrapper. It is not native WPF and therefore does not respect the ZOrder
of WPF apps.
Upvotes: 3
Reputation: 4302
No, you can't do it with the WPF WebBrowser that originally ship with SDK.
It always on top of other UIElement
.
But I think it is possible with 3rd party control.
For detail take a look in this question I asked before.
Upvotes: 5