How do I get a WPF command to execute on double-clicking a row in a WPF Infragistics WPF data file?

I have a WPF XamDataGrid (I am using MVVM pattern, below xaml) and I need it to display record data in another window when user double clicks on a row. I have a command that does the job, but I don't know how to run it, like with buttons. I want to be able to execute a command when the user double-clicks a string, so I need to send the double-clicked string (or its ID) as a parameter to the command. Is it possible?

<igDP:XamDataGrid DataSource="{Binding SomeList}">
                <igDP:FieldLayoutSettings AutoGenerateFields="False"/>
                <igDP:FieldLayout >
                        <igDP:Field  Name="ObjectId" Label="Id" Width="Auto"/>
                        <igDP:Field  Name="Description" Label="Object Description" Width="Auto"/>



source to share

3 answers

I also use MVVM pattern and write for example:

<igDP:XamDataGrid ItemsSource={Binding Path=StaffList, Mode=OneWay}>
    <MouseBinding MouseAction="LeftDoubleClick" 
                  Command="{Binding Path=EditStaffCommand, Mode=OneWay}" 
                  CommandParameter="{Binding Path=DataItem}"/>


Where EditStaffCommand

and StaffList

are properties from the view model



Take a look at the behavior of Attached commands ( ). They allow you to associate commands with events.



You can create a behavior to add binding between your ViewModels command and the Double Click event for the Grid.

For more information, see the following message:



All Articles