Throw Application event from button click event handler
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace PreventSessionEnd
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void cmdException_Click(object sender, RoutedEventArgs e)
{
throw new ApplicationException("You clicked a bad button.");
}
}
}