protected virtual void LoadWindowState() { if (_settings == null) { return; } _settings.Reload(); if (_settings.Placement == null) { return; } try { var wp = _settings.Placement; wp.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT)); wp.flags = 0; wp.showCmd = (wp.showCmd == Constants.SW_SHOWMINIMIZED ? Constants.SW_SHOWNORMAL : wp.showCmd); var hwnd = new WindowInteropHelper(_window).Handle; NativeMethodsUltimate.SetWindowPlacement(hwnd, wp); } catch (Exception ex) { Debug.WriteLine("Failed to load window state:\r\n{0}", ex); } }