Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
PreviewKeyDown/KeyUp not tunnelling
Message
From
05/03/2010 13:09:36
 
 
To
05/03/2010 12:42:04
John Baird
Coatesville, Pennsylvania, United States
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01452829
Message ID:
01452838
Views:
35
>>Hi,
>>Very simple WPF window:
<Window x:Class="TabTest.Window3"
>>    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
>>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
>>    <Canvas x:Name="Outer" Width="500" Height="500" Background="Beige">
>>        <ScrollViewer x:Name="SV" Width="500" Height="500" >
>>            <Canvas x:Name="Inner" Width="1000" Height="1000" Background="Red" ></Canvas>
>>        </ScrollViewer>
>>    </Canvas>
>></Window>
No Key events (i.e. PreviewKeyDown,KeyDown,PreviewKeyUp,KeyUp) fire on the 'Inner' Canvas.
>>The ScrollViewer behaves as I would expect by eating the KeyDown for 'action' keys such as the arrow keys - but I thought the other events would drill down to the inner canvas.
>>
>>What am I missing .......
>stupid question, but I think it bubbles by default. Have you set it to tunnel?

It should tunnel then bubble automatically. If I handle *all* the events in the example I see:

Outer PreviewKeyDown
SV PreviewKeyDown
SV KeyDown
Outer KeyDown
Outer PreviewKeyUp
SV PreviewKeyUp
SV KeyUp
Outer KeyUp

If I press, say, the downarrow this changes to :

Outer PreviewKeyDown
SV PreviewKeyDown
Outer PreviewKeyUp
SV PreviewKeyUp
SV KeyUp
Outer KeyUp

i.e the ScrollViewer eats the ScrollViewer.KeyDown so I lose that plus the Outer.KeyDown since it's marked as handled But that's OK - I was expecting it. But *no* events penetrate down to the 'inner' canvas. :-{
Previous
Reply
Map
View

Click here to load this message in the networking platform