Browse Source

Add WindowClosed and WindowOpened property

pull/8147/head
Wiesław Šoltés 4 years ago
parent
commit
6e2dea0fa0
  1. 27
      src/Avalonia.Controls/Window.cs

27
src/Avalonia.Controls/Window.cs

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

Loading…
Cancel
Save