TreeListView.AddingNewNodeCommand Property
Gets or sets a command that is executed before a new node is added to the GridControl.
Namespace: DevExpress.Xpf.Grid
Assembly: DevExpress.Xpf.Grid.v24.2.dll
NuGet Package: DevExpress.Wpf.Grid.Core
Declaration
Property Value
Type | Description |
---|---|
ICommand<NewNodeArgs> | A command that is executed before a new node is added to the GridControl. |
Remarks
Bind a command to the AddingNewNodeCommand
property to maintain a clean MVVM pattern. The command works like an AddingNewNode event handler and allows you to specify a new data record in a View Model.
A command bound to the AddingNewNodeCommand 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 ItemsSource="{Binding Products}">
<dxg:GridControl.View>
<dxg:TreeListView NewItemRowPosition="Top"
AddingNewNodeCommand="{Binding AddingNewNodeCommand}"/>
</dxg:GridControl.View>
</dxg:GridControl>
[Command]
public void AddingNewNode(NewNodeArgs args) {
args.Item = new Product() {
ProductName = "",
CompanyName = "New Company",
UnitPrice = 10,
Discontinued = false
};
}
Note
The AddingNewNodeCommand property does not call the bound command when you add a new node directly to a bound data source.
Refer to the following help topic for more information: Add and Remove Rows.