问题
can give somebody me a hint how to display "overlay controls" in the WebBrowser control in my WPF application? I'd like to display navigation graphics as overlay so the user can select a function and the navigation controls disapear after selecting it.
not really experienced in WPF for now. :( i have no idea where to start. any hint or link would be great. thank you
回答1:
There are going to be issues with this. there are "airspace" issues with the WPF browser control. basically, it means you can't put anything over the top of the browser control.
The work around is to put your overlaid controls into a popup control.
回答2:
I found a way past this, though it's a bit of a hack. Essentially you create your controls as WinForm controls and use a WindowsFormsHost to host them.
WindowsFormsHost will sit on top of a web browser control.
As I said, not ideal but will work if you're desperate.
回答3:
There is a wpf based browser that uses Chromium. It should allow you to treat it like any other wpf object rather then the activex browser control.
回答4:
It is tough to get through Air space of WPF web browser control, However, you could minimise the height of web browser control when displaying your animation and set the height again when your task is over.
The better workaround for this issue is by handling the height of browser control. Find a simple scenario below.
Assume, you have a web browser control in Mainwindow. When you perform some action,, eg: click a button you have another user control which comes above MainWindow. However, because of Airspace issue the web browser doesn't sit in its parent control and comes on top of your control.
FIX: The standard fix is you can set the height of web browser to zero when you trigger some other control over it depends upon your scenario. Below, there is a sample implementation.
In MainWindow.Xaml include the events.
Activated="Window_Activated"
Deactivated="Window_Deactivated"
In Xaml.cs handle the scenario by setting the height.
private void Window_Activated(object sender, EventArgs e)
{
wb.Height = double.NaN;
}
private void Window_Deactivated(object sender, EventArgs e)
{
wb.Height = 0;
}
来源:https://stackoverflow.com/questions/1527667/overlay-for-webbrowser-control-in-wpf-application