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: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>

      

+3


source to share


3 answers


I also use MVVM pattern and write for example:

<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

are properties from the view model

+5


source


Take a look at the behavior of Attached commands ( http://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2-aka-acb/ ). They allow you to associate commands with events.



+2


source


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:

http://blogs.infragistics.com/forums/p/67749/343013.aspx#343013

0


source







All Articles