diff --git a/src/Perspex.Controls/Primitives/PopupRoot.cs b/src/Perspex.Controls/Primitives/PopupRoot.cs index a685f03071..de8b1f5fe3 100644 --- a/src/Perspex.Controls/Primitives/PopupRoot.cs +++ b/src/Perspex.Controls/Primitives/PopupRoot.cs @@ -84,6 +84,7 @@ namespace Perspex.Controls.Primitives /// public void Show() { + EnsureInitialized(); PlatformImpl.Show(); LayoutManager.Instance.ExecuteInitialLayoutPass(this); IsVisible = true; @@ -108,6 +109,16 @@ namespace Perspex.Controls.Primitives } } + private void EnsureInitialized() + { + if (!this.IsInitialized) + { + var init = (ISupportInitialize)this; + init.BeginInit(); + init.EndInit(); + } + } + private void SetTemplatedParentAndApplyChildTemplates(IControl control) { var templatedParent = Parent.TemplatedParent; diff --git a/src/Perspex.Controls/Window.cs b/src/Perspex.Controls/Window.cs index 94437825cb..7692f22e01 100644 --- a/src/Perspex.Controls/Window.cs +++ b/src/Perspex.Controls/Window.cs @@ -204,6 +204,7 @@ namespace Perspex.Controls { s_windows.Add(this); + EnsureInitialized(); LayoutManager.Instance.ExecuteInitialLayoutPass(this); using (BeginAutoSizing()) @@ -236,6 +237,7 @@ namespace Perspex.Controls { s_windows.Add(this); + EnsureInitialized(); LayoutManager.Instance.ExecuteInitialLayoutPass(this); using (BeginAutoSizing()) @@ -311,5 +313,15 @@ namespace Perspex.Controls base.HandleResized(clientSize); } + + private void EnsureInitialized() + { + if (!this.IsInitialized) + { + var init = (ISupportInitialize)this; + init.BeginInit(); + init.EndInit(); + } + } } }