Skip to main content
A newer version of this page is available. .
All docs
V21.1

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.1.dll

NuGet Package: DevExpress.Wpf.Grid.Core

Declaration

public ICommand<NewRowArgs> AddingNewRowCommand { get; set; }

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 AddingNewRow property to maintain a clean MVVM pattern. The command works like an AddingNewRow event handler and allows you to process the row add operation in a View Model.

The code sample below demonstrates how to initialize cells displayed within the New Item Row with a new value:

<dxg:GridControl>
    <dxg:GridControl.View>
        <dxg:TableView NewItemRowPosition="Top" AddingNewRowCommand="{Binding AddNewRow}" />
    </dxg:GridControl.View>
</dxg:GridControl>

Assign a data record to the NewRowArgs.Item property as follows:

[Command]
void AddNewRow(NewRowArgs args) {
    args.Item = new DataRow();
}

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.

See Also