1

I'm using the DevExpress XPF GridControl's NewItemRow for adding new row to my database. How to get the user entered data from new row. Am using prism framework. Here is my xaml

         <dxg:GridControl.View>
            <dxg:TableView AutoWidth="True" AllowEditing="True" NewItemRowPosition="Top">       
                <dxmvvm:Interaction.Behaviors>
                    <dxmvvm:EventToCommand EventName="RowUpdated" 
                                           Command="{Binding RowUpdateClickCommand}" CommandParameter="{Binding CurrentItem}"/>
                </dxmvvm:Interaction.Behaviors>
            </dxg:TableView>
        </dxg:GridControl.View>
PRK
  • 177
  • 1
  • 4
  • 15

1 Answers1

1

To get information about the updated row, you can pass EventArgs to your command. To accomplish this task, set the EventToCommand.PassEventArgsToCommand property to true:

<dxmvvm:EventToCommand EventName="RowUpdated" PassEventArgsToCommand="True"
                        Command="{Binding RowUpdateClickCommand}"/>

To determine that a user modified NewItemRow, you can compare RowEventArgs.RowHandle with the static GridControl.NewItemRowHandle property:

public class MyViewModel {
    public MyViewModel() {
        RowUpdateClickCommand = new DelegateCommand<RowEventArgs>(RowUpdateClick);
    }
    public ICommand RowUpdateClickCommand {
        get;
        set;
    }
    public void RowUpdateClick(RowEventArgs e) {
        if (e.RowHandle == GridControl.NewItemRowHandle) {
            //e.Row -  new row is here
        }
    }
}

Please note that if you don't wish to pass event args to the view model level, you can convert them using EventArgsConverter

Alex Russkov
  • 323
  • 2
  • 8
  • How to pass this event to view model? can you share some exmple – PRK Jun 20 '17 at 18:48
  • I have updated my answer to demonstrate how to define the command so that it accepts RowEventArgs. When you set PassEventArgsToCommand to true, EventToCommand will automatically pass event args to the command when the event is raised – Alex Russkov Jun 21 '17 at 06:58