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?
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?
I also had a similar issue where I needed to bind the MouseDoubleClick event of a listview to a command in my ViewModel.
The simplest solution I came up is putting a dummy button which has the desired command binding and calling the Execute method of the button's command in the eventhandler of the MouseDoubleClick event.
.xaml
codebehind
It is not straightforward but it is really simple and it works.
Try Marlon Grech's attached command behaviors.
http://thejoyofcode.com/Invoking_a_Command_on_a_Double_Click_or_other_Mouse_Gesture.aspx
it's simple let's use the MVVM way: I'm using here MVVM Light which is easy to learn and strong.
1.put the following lines the xmlns declarations :
2.define your textblock just like this:
3.then write your command code in your viewmodel !!!
ViewModel1.cs
I hope that works for you as I have used it in Real ERP application