I have a WPF XamDataGrid (I'm using the MVVM pattern, xaml below) and I need it to show the record details in another window when the user double clicks on a row. I have the command which gets the job done, but I don't know how to fire it up as I do with buttons. I want to be able to execute the command when the user double clicks a row, so I need to send the double clicked row (or its ID) as a parameter to the comand. Is it possible?
<igDP:XamDataGrid DataSource="{Binding SomeList}">
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings AutoGenerateFields="False"/>
</igDP:XamDataGrid.FieldLayoutSettings>
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout >
<igDP:FieldLayout.Fields>
<igDP:Field Name="ObjectId" Label="Id" Width="Auto"/>
<igDP:Field Name="Description" Label="Object Description" Width="Auto"/>
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
I use MVVM pattern too and write such as:
<igDP:XamDataGrid ItemsSource={Binding Path=StaffList, Mode=OneWay}>
...
<igDP:XamDataGrid.InputBindings>
<MouseBinding MouseAction="LeftDoubleClick"
Command="{Binding Path=EditStaffCommand, Mode=OneWay}"
CommandParameter="{Binding Path=DataItem}"/>
</igDP:XamDataGrid.InputBindings>
...
</igDP:XamDataGrid>
Where EditStaffCommand
and StaffList
- properties from view model
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With