diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index a5f99918b2..3a8a721eec 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -171,15 +171,14 @@ namespace Avalonia.Controls /// /// Routed event that can be used for global tracking of window destruction /// - public static readonly RoutedEvent WindowClosedEvent = - RoutedEvent.Register("WindowClosed", RoutingStrategies.Direct); + public static readonly RoutedEvent WindowClosedEvent = + RoutedEvent.Register(nameof(WindowClosed), RoutingStrategies.Direct); /// /// Routed event that can be used for global tracking of opening windows /// - public static readonly RoutedEvent WindowOpenedEvent = - RoutedEvent.Register("WindowOpened", RoutingStrategies.Direct); - + public static readonly RoutedEvent WindowOpenedEvent = + RoutedEvent.Register(nameof(WindowOpened), RoutingStrategies.Direct); private readonly NameScope _nameScope = new NameScope(); @@ -446,6 +445,24 @@ namespace Avalonia.Controls } } + /// + /// Routed event that can be used for global tracking of window destruction. + /// + public event EventHandler? WindowClosed + { + add => AddHandler(WindowClosedEvent, value); + remove => RemoveHandler(WindowClosedEvent, value); + } + + /// + /// Routed event that can be used for global tracking of opening windows. + /// + public event EventHandler? WindowOpened + { + add => AddHandler(WindowOpenedEvent, value); + remove => RemoveHandler(WindowOpenedEvent, value); + } + /// /// Starts moving a window with left button being held. Should be called from left mouse button press event handler ///