void DetatchWindow() { if (ContentWindow != null) { ContentWindow.Closed -= ContentWindow_Closed; ContentWindow.ContentRendered -= ContentWindow_ContentRendered; if (hWndContent != IntPtr.Zero) { try { var hSrc = HwndSource.FromHwnd(hWndContent); if (hSrc != null) { hSrc.RemoveHook(WndProc); } } catch { } } ContentWindow = null; } _left?.Close(); _top?.Close(); _right?.Close(); _bottom?.Close(); }
void DetatchWindow() { if (ContentWindow != null) { ContentWindow.Closed -= ContentWindow_Closed; ContentWindow.ContentRendered -= ContentWindow_ContentRendered; var dpd = DependencyPropertyDescriptor.FromProperty(FrameworkElement.FlowDirectionProperty, typeof(Window)); if (dpd != null) { dpd.RemoveValueChanged(ContentWindow, HandleFlowDirChange); } ContentWindow = null; } _left.Close(); _top.Close(); _right.Close(); _bottom.Close(); }