Hi,
We are trying to strictly implement MVVM in our application which uses the xamDataGrid extensively. For instance when you click on a button we are able to call a method in our associated ViewModel class using the standard binding syntax:<Button Name="btnAddTrade" Command="{Binding Path=AddTrade}" />This works fine for button clicks etc. where you can specify a "Command" (which is a DelegateCommand in the associated ViewModel class.Even works for right click items on the xamDataGrid such as:<MenuItem Header="Split" Name="cmnuSplitTrade" Command="{Binding Path=SplitCommand}" />
My question is - how to implement something similar for a double click event on the xamDataGrid ?e.g. <igDP:XamDataGrid DataSource="{Binding Path=TradeResults}" MouseDoubleClick="{Binding Path=SomeMethod}">
I realise this syntax wont work but is there must be some way I can wire this event directly up to a ViewModel method..Does anyone know of a way this can be done without putting anything in the code behind file?Thanks in advance!
Thanks for posting this question Ainsley - I was browsing this forum with the same question in mind..(in a SIlverlight context) :-)
Sorry for my late reply. I'm sidestepping passing the record by going with a MVVM approach and just binding the active record of the grid to a property on my view model. My XamDataGrid WPF declaration looks like this:
<igDP:XamDataGrid
Name="gridSearchResults"
Grid.Row="1"
TabIndex="3"
Theme="Office2k7Blue"
DataSource="{Binding Path=SearchResults}"
IsSynchronizedWithCurrentItem="True"
AutoFit="True"
Margin="0,5,0,0"
FontSize="11"
ActiveDataItem="{Binding Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged, Path=ActiveRecord}"
vm:CommandBroker.GridDoubleClickCommand="{Binding Path=GridDoubleClickCommand}">
I hope that helps,
Steve
I see the issue fixed for the DataContext, but for DoubleClick on XamDataGrid, I'm quite not sure how to pass the record on which the doubleclick was performed. Can you suggest a way to do this using the example that you provided?
Thanks,
shravan
Bobs,
I've been using the technique demonstrated here to bind my ViewModel commands to pretty much any control events (including IG grid DoubleClick) that are required. It's a bit bulky and there are likely some better ways to do it but it's been working well for a while now.
Hah, just realized I posted in this thread already (too many things going on...) but yeah, the techniques used in the above link are still working well.
</s>
Hello,
You can try creating a TargetedTriggerAction<T> for the XamDataGrid using the Microsoft.Expressions.Interaction library. You can see a similar examples here.