Application .Activated Event

Objective to learn Application:

Application is a class that encapsulates WPF application-specific functionality, including the following:
  • Application Lifetime: Activated, Current, Deactivated, DispatcherUnhandledException, Exit, Run, SessionEnding, Shutdown, ShutdownMode, Startup.
  • Application-Scope Window, Property, and Resource Management: FindResource, GetContentStream, GetResourceStream, LoadComponent, MainWindow, Properties, Resources, StartupUri, Windows.
  • Command-Line Parameter and Exit Code Processing: Application Startup , Application Exit , Application Shutdown .
  • Navigation: FragmentNavigation, LoadCompleted, Navigated, Navigating, NavigationProgress, NavigationStopped, NavigationFailed, GetCookie.

Codes : App.xaml.txt, App.xaml.cs.txt, MainWindow.xaml.txt, MainWindow.xaml.cs.txt

Activated is not raised for XAML browser applications (XBAPs).

Step: 1 Create a new project

The IDE creates two classes , MainWindow and App

Edit the code in Class App.

Code in  App.xaml

Code in App.xaml.cs

Now change Main window

Runtime

During activation you will note message popup; Now click on Exit

The Clicking Exit button, would shut down the current application. However this can be overridden with a method in App class " App_Exit"