I have a WPF where I am implementing a WebBrowser control and I have a list of objects that when i select them it changes the url binding for the webBrowser control and all is well.

However, if the web page I am on tries to close the Webpage, a dialog pops up where you can hit yes or no to close the "window" (the WebBrowser control)

if the user hits "yes" then the web browser control is closed and exceptions are thrown when you try to select something else in the list because the window doesn't exist anymore.

The webbrowser control does not have a method for closing exposed where i can get to it and I was able to override the "Window.Close()" method but that also prevented me from closing the main app window.

I have tried inheriting from the webBrowser class but it is sealed so i can't inherit to add event handlers or override methods such as "Close()" or event such as "OnClosing()"

so my question is

A. Is it possible to intercept the dialog and always say "no"?

or

B. Is there another way to prevent the window from closing even if the person says "yes" to the dialog?

Thanks in advance...