Activated and Deactivated events monitors the activation status of an application.

image_pdfimage_print
   
  

<Application
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="ActivationSample.App"
    StartupUri="MainWindow.xaml"
    Startup="App_Startup" 
    Activated="App_Activated" 
    Deactivated="App_Deactivated"
    Exit="App_Exit">
</Application>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Threading;

namespace ActivationSample
{
    public partial class App : System.Windows.Application
    {
        void App_Startup(object sender, StartupEventArgs e)
        {
        }
        void App_Activated(object sender, EventArgs e)
        {
            Console.WriteLine("App_Activated");
        }
        void App_Deactivated(object sender, EventArgs e)
        {
            Console.WriteLine("Deactivated");
        }
        void App_Exit(object sender, ExitEventArgs e)
        {
            Console.WriteLine("Exit");
        }
    }
}