WPF RibbonSplitButton 不会触发 MouseDown 或 MouseLeftButtonDown 事件

WPF RibbonSplitButton doesn't fire MouseDown or MouseLeftButtonDown event

我在我的应用程序中使用带有三个子项的 RibbonSplitButton。 当我一直点击按钮时,我开始一个程序,当按钮被释放时我停止。问题是 RibbonSplitButton 不会触发任何事件(单击异常事件)。同样的工作也应该由 RibbonMenuItem 完成。 这是我的代码: XAML

<ribbon:RibbonSplitButton LargeImageSource="images/move.png"
                      Label="Muovi"
                      //incriminated methods
                      MouseLeftButtonDown="Movimento_StartContinuous"
                      MouseDown="Movimento_StartContinuous"
                      MouseLeftButtonUp="Movimento_StopContinuous"
                      TouchUp="Movimento_StopContinuous"
                      TouchDown="Movimento_StartContinuous"
                      //yeah, this work well
                      Click="Movimento_StartContinuous">
    <ribbon:RibbonMenuItem Header="Veloce"
                           //incriminated methods
                           MouseLeftButtonDown="Movimento_StartContinuous_Veloce"
                           MouseLeftButtonUp="Movimento_StopContinuous" />
    <ribbon:RibbonMenuItem Header="Normale"/>
    <ribbon:RibbonMenuItem Header="Lento"/>
</ribbon:RibbonSplitButton>

代码隐藏

private void Movimento_StartContinuous(object sender, RoutedEventArgs e) {
    //never go here
    e.Handled = true;
}
private void Movimento_StartContinuous(object sender, System.Windows.Input.TouchEventArgs e) {
    //never go here
    e.Handled = true;
}

我哪里弄错了?

最上面的元素可能是 swallow 这些事件(您通过将 e.Handled 设置为 true 也吞噬了它们,但这些处理程序永远不会被调用正如你所说。)。您可以尝试处理预览事件 (PreviewMouseLeftButtonDownPreviewTouchDown)。

注意:并非每个活动都有预览版。大多数与输入相关的事件都有预览版,但例如 Click 事件没有。