
 1 <Window x:Class="RoutedEvents.TunneledKeyPress"
 2     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 3     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 4     Title="TunneledKeyPress" Height="411" Width="403"
 5      PreviewKeyDown="SomeKeyPressed" 
 6 >
 7   <Grid Margin="3">
 8     <Grid.RowDefinitions>
 9       <RowDefinition Height="Auto"></RowDefinition>
10       <RowDefinition Height="*"></RowDefinition>
11       <RowDefinition Height="Auto"></RowDefinition>
12       <RowDefinition Height="Auto"></RowDefinition>
13     </Grid.RowDefinitions>
14 
15     <Label Margin="5" Background="AliceBlue" BorderBrush="Black" BorderThickness="1" HorizontalContentAlignment="Stretch"
16            PreviewKeyDown="SomeKeyPressed">
17       <StackPanel
18 PreviewKeyDown="SomeKeyPressed">
19         <TextBlock Margin="3" HorizontalAlignment="Center"
20                    PreviewKeyDown="SomeKeyPressed">
21           Image and text label
22         </TextBlock>
23         <Image Source="happyface.jpg" Stretch="None" 
24                 PreviewKeyDown="SomeKeyPressed"/>
25         <DockPanel Margin="0,5,0,0" PreviewKeyDown="SomeKeyPressed">
26           <TextBlock Name="txt1" Margin="3" 
27                      PreviewKeyDown="SomeKeyPressed">
28           Type here:
29         </TextBlock>
30           <TextBox PreviewKeyDown="SomeKeyPressed" KeyDown="SomeKeyPressed"></TextBox>
31         </DockPanel>
32       </StackPanel>
33     </Label>
34 
35     <ListBox Margin="5" Name="lstMessages" Grid.Row="1"></ListBox>
36     <CheckBox Margin="5" Grid.Row="2" Name="chkHandle">Handle first event</CheckBox>
37     <Button Click="cmdClear_Click" Grid.Row="3" HorizontalAlignment="Right" Margin="5" Padding="3">Clear List</Button>
38   </Grid>
39 </Window>
 
