<Window x:Class="RoutedEvents.KeyPressEvents"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="KeyPressEvents" Height="387" Width="368" 
    >
    <Grid>
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"></RowDefinition>
        <RowDefinition Height="*"></RowDefinition>
        <RowDefinition Height="Auto"></RowDefinition>
        <RowDefinition Height="Auto"></RowDefinition>
      </Grid.RowDefinitions>
      
          <DockPanel Margin="5">
            <TextBlock Margin="3" >
              Type here:
            </TextBlock>
            <TextBox PreviewKeyDown="KeyEvent" KeyDown="KeyEvent" 
                     PreviewKeyUp="KeyEvent" KeyUp="KeyEvent"
                     PreviewTextInput="TextInput"
                     TextChanged="TextChanged"></TextBox>
          </DockPanel>

      <ListBox Margin="5" Name="lstMessages" Grid.Row="1"></ListBox>
      <CheckBox Margin="5" Name="chkIgnoreRepeat" Grid.Row="2">Ignore Repeated Keys</CheckBox>
      <Button Click="cmdClear_Click" Grid.Row="3" HorizontalAlignment="Right" Margin="5" Padding="3">Clear List</Button>
    
    </Grid>
</Window>
