private void Hook() { var handle = new WindowInteropHelper(this).EnsureHandle(); _monitor = new Monitor(handle); _window = new Native.Window(handle); UpdateNonClientBorder(); var source = HwndSource.FromHwnd(handle); if (source != null) { source.AddHook(WndProc); } }