diff --git a/src/Perspex.Controls/Window.cs b/src/Perspex.Controls/Window.cs index ae12a4d6ed..94437825cb 100644 --- a/src/Perspex.Controls/Window.cs +++ b/src/Perspex.Controls/Window.cs @@ -10,6 +10,7 @@ using Perspex.Layout; using Perspex.Media; using Perspex.Platform; using Perspex.Styling; +using System.Collections.Generic; namespace Perspex.Controls { @@ -44,6 +45,13 @@ namespace Perspex.Controls /// public class Window : TopLevel, IStyleable, IFocusScope, ILayoutRoot, INameScope { + private static IList s_windows = new List(); + + /// + /// Retrieves an enumeration of all Windows in the currently running application. + /// + public static IList OpenWindows => s_windows; + /// /// Defines the property. /// @@ -153,6 +161,7 @@ namespace Perspex.Controls /// public void Close() { + s_windows.Remove(this); PlatformImpl.Dispose(); } @@ -193,6 +202,8 @@ namespace Perspex.Controls /// public void Show() { + s_windows.Add(this); + LayoutManager.Instance.ExecuteInitialLayoutPass(this); using (BeginAutoSizing()) @@ -223,6 +234,8 @@ namespace Perspex.Controls /// public Task ShowDialog() { + s_windows.Add(this); + LayoutManager.Instance.ExecuteInitialLayoutPass(this); using (BeginAutoSizing())