Skip to main content

IClassicDesktopStyleApplicationLifetime Interface

Definition​

Assembly:Avalonia.Controls
Package:Avalonia

Controls application lifetime in classic desktop style

public interface IClassicDesktopStyleApplicationLifetime

Methods​

NameDescription
TryShutdownTries to Shutdown the application. Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime.ShutdownRequested event can be used to cancel the shutdown.

TryShutdown Method​

Tries to Shutdown the application. Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime.ShutdownRequested event can be used to cancel the shutdown.

public bool TryShutdown(int exitCode)

Parameters​

exitCode int

An integer exit code for an application. The default exit code is 0.

Returns​

bool

Properties​

NameDescription
ArgsGets the arguments passed to the Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(Avalonia.AppBuilder,string[],Avalonia.Controls.ShutdownMode) method.
MainWindowGets or sets the main window of the application.
ShutdownModeGets or sets the Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime.ShutdownMode. This property indicates whether the application is shutdown explicitly or implicitly. If Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime.ShutdownMode is set to OnExplicitShutdown the application is only closes if Shutdown is called. The default is OnLastWindowClose
WindowsGets the list of all open windows in the application.

Args Property​

Gets the arguments passed to the Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(Avalonia.AppBuilder,string[],Avalonia.Controls.ShutdownMode) method.

public string[] Args { get; set; }

MainWindow Property​

Gets or sets the main window of the application.

public Avalonia.Controls.Window MainWindow { get; set; }

Value​

The main window.

ShutdownMode Property​

Gets or sets the Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime.ShutdownMode. This property indicates whether the application is shutdown explicitly or implicitly. If Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime.ShutdownMode is set to OnExplicitShutdown the application is only closes if Shutdown is called. The default is OnLastWindowClose

public Avalonia.Controls.ShutdownMode ShutdownMode { get; set; }

Value​

The shutdown mode.

Windows Property​

Gets the list of all open windows in the application.

public System.Collections.Generic.IReadOnlyList<Avalonia.Controls.Window> Windows { get; set; }

Events​

NameDescription
ShutdownRequestedRaised by the platform when an application shutdown is requested.

ShutdownRequested Event​

Raised by the platform when an application shutdown is requested.

public event EventHandler<Avalonia.Controls.ApplicationLifetimes.ShutdownRequestedEventArgs> ShutdownRequested

Remarks​

Application Shutdown can be requested for various reasons like OS shutdown.

On Windows this will be called when an OS Session (logout or shutdown) terminates. Cancelling the eventargs will block OS shutdown.

On OSX this has the same behavior as on Windows and in addition: This event is raised via the Quit menu or right-clicking on the application icon and selecting Quit.

This event provides a first-chance to cancel application shutdown; if shutdown is not canceled at this point the application will try to close each non-owned open window, invoking the Avalonia.Controls.Window.Closing event on each and allowing each window to cancel the shutdown of the application. Windows cannot however prevent OS shutdown.