The WebBrowser control is not a usual wpf control. Its an activeX host that hosts the browser inside a new window that is drawn on top of your wpf window. This is known as the windows 'Airspace issue'.
This is why setting the IsEnabled property or placing another control on top of it does not work.
Since the WebBrowser has its own window, the only way to prevent mouse input to your web page is to prevent mouse input to the browsers window. You can do this with an external call to EnableWindow(IntPtr hWnd, bool enable)
.
Here is a small sample:
MainWindow.xaml:
<Window x:Class="Test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MainWindow"
Width="800"
Height="450"
mc:Ignorable="d">
<Grid>
<WebBrowser x:Name="Browser"/>
</Grid>
</Window>
MainWindow.xaml.cs:
namespace Test
{
static class Win32
{
[DllImport("user32.dll")]
public static extern bool EnableWindow(IntPtr hWnd, bool enable);
}
public partial class MainWindow : Window
{
public MainWindow()
{
Loaded += MainWindow_Loaded;
}
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
Win32.EnableWindow(Browser.Handle, false);
}
}
}
This will disable all mouse and keyboard inputs to the browser window.