I'm using a RibbonSplitButton in my application with three sub item. When I keep clicked the button I start a procedure that I stop when the button is released. The problem is the RibbonSplitButton doesn't fires any events (with the event of the click exception). The same work should be done also by RibbonMenuItem. This is my code: 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>
Code Behind
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;
}
Where I make a mistake?
The topmost elements are probably swallow these events (you're swallowing them too by setting e.Handled
to true
, but these handlers are never invoked as you say.). You can try handling the preview events instead (PreviewMouseLeftButtonDown
, PreviewTouchDown
).
Note: Not every event has a preview version. Most of input related events have a preview version, but for example the Click
event doesn't.