diff --git a/src/Windows/Perspex.Designer/AppHost/WindowHost.cs b/src/Windows/Perspex.Designer/AppHost/WindowHost.cs index a98850bcf3..e598e4cb6e 100644 --- a/src/Windows/Perspex.Designer/AppHost/WindowHost.cs +++ b/src/Windows/Perspex.Designer/AppHost/WindowHost.cs @@ -25,6 +25,8 @@ namespace Perspex.Designer.AppHost SetStyle(ControlStyles.AllPaintingInWmPaint, true); Controls.Add(_windowHost); _windowHost.Anchor = AnchorStyles.None; + if (!supportScroll) + _windowHost.Visible = false; _timer.Tick += delegate { ReloadSettings(); @@ -98,7 +100,7 @@ namespace Perspex.Designer.AppHost _hWnd = hWnd; if (_hWnd != IntPtr.Zero) { - WinApi.SetParent(hWnd, _windowHost.Handle); + WinApi.SetParent(hWnd, _supportScroll ? _windowHost.Handle : Handle); FixWindow(); } } @@ -127,8 +129,6 @@ namespace Perspex.Designer.AppHost } else { - _windowHost.Width = Width; - _windowHost.Height = Height; WinApi.MoveWindow(_hWnd, 0, 0, Width, Height, true); } } diff --git a/src/Windows/Perspex.Designer/PerspexDesigner.xaml.cs b/src/Windows/Perspex.Designer/PerspexDesigner.xaml.cs index ad4488d5c6..1b394a0f7d 100644 --- a/src/Windows/Perspex.Designer/PerspexDesigner.xaml.cs +++ b/src/Windows/Perspex.Designer/PerspexDesigner.xaml.cs @@ -73,14 +73,16 @@ namespace Perspex.Designer { if (e.PropertyName == nameof(ProcessHost.WindowHandle)) { - if (NativeContainer.Child == null) + if (NativeContainer.Child != null) { - NativeContainer.Child = new WindowHost(false); - } - { - var wndHost = ((WindowHost) NativeContainer.Child); - wndHost.SetWindow(_host.WindowHandle); + var child = NativeContainer.Child; + NativeContainer.Child = null; + child.Dispose(); } + NativeContainer.Child = new WindowHost(false); + var wndHost = ((WindowHost) NativeContainer.Child); + wndHost.SetWindow(_host.WindowHandle); + } }