OnMouseイベントを子に表示させようとしていますFrameworkElement
。親要素はaですPanel
(Background
プロパティはNullではありません)。
class MyFrameworkElement : FrameworkElement
{
protected override void OnMouseDown(MouseButtonEventArgs e)
{
// Trying to get here!
base.OnMouseDown(e);
}
}
public class MyPanel : Panel
{
protected override void OnMouseDown(MouseButtonEventArgs e)
{
// This is OK
base.OnMouseDown(e);
}
}
OnMouseが呼び出されることはなく、イベントは常に処理されず、Snoopは、ルーティングされたイベントがPanel
要素までしか到達していないように見えることを通知します。
<Window
x:Class="WpfApplication5.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:l="clr-namespace:WpfApplication5"
Title="Window1" Height="300" Width="300">
<Border x:Name="myBorder" Background="Red">
<l:MyPanel x:Name="myPanel" Background="Transparent">
<l:MyFrameworkElement x:Name="myFE"/>
</l:MyPanel>
</Border>
</Window>
ドキュメントはそれが入力を処理すると言いますFrameworkElement
が、なぜこのシナリオではないのですか?