WPF:点击用户控件背景不触发

WPF: Click on Usercontrols Background does not fire

我有一个 WPF 用户控件,它经过简化后看起来像这样:

<UserControl Name="NiceUserControl" MouseLeftButtonUp="NiceUserControl_MouseLeftButtonUp">
    <Grid MouseDown="Grid_MouseDown">
        <Border>
           <A lot Of Different Stuff like Buttons and Other usercontrols>
        </Border>
    </Grid>
</UserControl>

像这样,当单击 UserControl 中的子元素之一时,Usercontrol 中的事件 "MouseLeftButtonUp" 会触发,但当我单击我的控件的(空)背景时则不会。 "Professional" Demo: 点击绿色元素触发,点击红色背景不触发:(

我还尝试添加此事件处理程序,根据其最后一个参数,当事件已处理时应忽略:

        NiceUserControl.AddHandler(MouseDownEvent, new MouseButtonEventHandler(NiceUserControl_MouseDown), true);

但这只对我的用户控件上的文本框有帮助,- 背景仍然没有触发。 甚至没有包含网格中的 PreviewMouse-Events 或 MouseEvents。

注意:例如,我希望控件内的按钮有自己的点击事件,但我希望它们也能触发用户控件的点击事件。

可能是你没有设置背景属性。