Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 566
bluebit Avatar asked Aug 18 '09 12:08

bluebit


People also ask

What is command binding in WPF?

The command is the action to be executed. The command source is the object which invokes the command. The command target is the object that the command is being executed on. The command binding is the object which maps the command logic to the command.


2 Answers

<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

like image 198
Legz Avatar answered Sep 27 '22 16:09

Legz


Try Marlon Grech's attached command behaviors.

like image 28
Kent Boogaart Avatar answered Sep 27 '22 16:09

Kent Boogaart