I have a ListBoxItem with a LeftClick Gesture:
<ListBoxItem x:Name="ListViewItemMenu" Content="{Binding Path=Header}" Padding="37 14" FontSize="15" Foreground="White">
<ListBoxItem.InputBindings>
<MouseBinding Gesture="LeftClick" Command="ApplicationCommands.New" />
</ListBoxItem.InputBindings>
</ListBoxItem>
But actually it's not a real Click, it's simply a MouseLeftButtonDown Gesture. The Command is executed regardless of whether the button is raised or not after pressed.
I would like to have a complete Click with the MouseDown and MouseUp Gestures in the ListBoxItem. There is anyway to do that? Much appreciated.
Also I can't find a way to add a Command to an Expander. The method shown above to the ListBoxItem doesn't work. Any magic here? Thanks!
According to this answer you can inherit from
MouseGestureto create custom gestures. There is even a full example with implementation.An alternative is to use an
System.Windows.Interactivity.EventTriggeras shown in this answer, which would let you turn theMouseLeftButtonUporPreviewMouseLeftButtonUpevent into a command trigger.