When you have one single WPF Window and its Content is a WebView, you could simulate reloading of the WebView, by disposing the old one and creating a new one. This causes the
OnVisualParentChanged to execute two times, for the old and new WebView. The Window is the same so the following code, window->LocationChanged += _handler; window->Deactivated += _handler;
executes two times. When the location of the Window changes the handler for the old, disposed view is invoked, which is incorrect and causes exceptions.
Unfortunately there are still few cases when Window::GetWindow(oldParent) returns null. The last commit stores the window reference, so that we could use it to unsubscribe from the events.
When you have one single WPF Window and its Content is a WebView, you could simulate reloading of the WebView, by disposing the old one and creating a new one. This causes the
OnVisualParentChanged
to execute two times, for the old and new WebView. The Window is the same so the following code,window->LocationChanged += _handler; window->Deactivated += _handler;
executes two times. When the location of the Window changes the handler for the old, disposed view is invoked, which is incorrect and causes exceptions.