Browse Source

Ensure Initialized gets called on TopLevels.

portable-xaml
Steven Kirk 10 years ago
parent
commit
616738ce1f
  1. 11
      src/Perspex.Controls/Primitives/PopupRoot.cs
  2. 12
      src/Perspex.Controls/Window.cs

11
src/Perspex.Controls/Primitives/PopupRoot.cs

@ -84,6 +84,7 @@ namespace Perspex.Controls.Primitives
/// </summary>
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;

12
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();
}
}
}
}

Loading…
Cancel
Save