The implementation of our button's Click event handler in Xaml

image_pdfimage_print


   
           

<Window x:Class="SimpleXamlApp.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>

  <x:Code>
  private void btnExitApp_Clicked(object sender, RoutedEventArgs e)
  {
    Application.Current.Shutdown();
  }
  </x:Code>
</Window>