Reputation: 107
We're using Views and ViewModels in this project, and as a result we're trying to have as little in the code-behind for the View as possible.
I'm trying to tie the MouseDoubleClick
event for a WPFToolkit DataGrid
to the same code that a Button
in the same view already is using.
The Button
is declared as the following:
<Button Content="Select" cmd:ButtonBaseExtensions.Command="{Binding CommandViewEmployer}"/>
which means it runs the CommandViewEmployer
Property in the ViewModel. How do I get the Grid
MouseDoubleClick
to run the same property? I've tried adding MouseDoubleClick="{Binding CommandViewEmployer}"
, which errors.
I'm trying to get this in as little code-behind as possible, none preferably.
Upvotes: 4
Views: 4474
Reputation: 178660
You can use something like Marlon Grech's attached command behaviors.
Upvotes: 2