<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="My Xaml App" Height="200" Width="300" WindowStartupLocation ="CenterScreen"> <Button Width="133" Height="24" Name="btnExitApp" Click ="btnExitApp_Clicked"> Exit Application </Button> </Window> //File:Window.xaml.cs using System; using System.Windows; using System.Windows.Controls; namespace WpfApplication1 { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void btnExitApp_Clicked(object sender, RoutedEventArgs e) { Application.Current.Shutdown(); } } }