GridViewBase.AddingNewRowCommand Property
Gets or sets a command that is executed before a new row is added to the GridControl.
Namespace: DevExpress.Xpf.Grid
Assembly: DevExpress.Xpf.Grid.v21.2.dll
NuGet Package: DevExpress.Wpf.Grid.Core
Declaration
Property Value
Type | Description |
---|---|
DevExpress.Mvvm.ICommand<NewRowArgs> | A command that is executed before a new row is added to the GridControl. |
Remarks
Bind a command to the AddingNewRowCommand property to maintain a clean MVVM pattern. The command works like an AddingNewRow event handler and allows you to specify a new data record in a View Model.
A command bound to the AddingNewRowCommand property is executed before the GridControl adds a new record to your data source. In this command, you can specify a data object and initialize its values.
<dxg:GridControl>
<dxg:GridControl.View>
<dxg:TableView NewItemRowPosition="Top"
AddingNewRowCommand="{Binding AddingNewRowCommand}"/>
</dxg:GridControl.View>
</dxg:GridControl>
[Command]
public void AddingNewRow(NewRowArgs args) {
args.Item = new Product(selectedCompany) {
ProductName = "",
CompanyName = "New Company",
UnitPrice = 10,
Discontinued = false
};
}
Note
The AddingNewRowCommand property does not call the bound command when you add a new row directly to a bound data source.
Refer to the following topic for information on how to add a new row to the GridControl: New Item Row.