How to bind a command in WPF to a double click event handler of a control?

bluebit picture bluebit · Aug 18, 2009 · Viewed 71.3k times · Source

I need to bind the double click event of a textblock (or potentially an image as well - either way, its a user control), to a command in my ViewModel.

TextBlock.InputBindings does not seem to bind correctly to my commands, any help?

Answer

Legz picture Legz · Jul 30, 2011
<Button>
<Button.InputBindings>
<MouseBinding Gesture="LeftDoubleClick" Command="YourCommand" />
</Button.InputBindings>
</Button>

http://thejoyofcode.com/Invoking_a_Command_on_a_Double_Click_or_other_Mouse_Gesture.aspx