Back to Devexpress

TreeListView.AddingNewNodeCommand Property

wpf-devexpress-dot-xpf-dot-grid-dot-treelistview-ee01a6ef.md

latest3.0 KB
Original Source

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.v25.2.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public ICommand<NewNodeArgs> AddingNewNodeCommand { get; set; }
vb
Public Property AddingNewNodeCommand As ICommand(Of NewNodeArgs)

Property Value

TypeDescription
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.

xaml
<dxg:GridControl ItemsSource="{Binding Products}">
    <dxg:GridControl.View>
        <dxg:TreeListView NewItemRowPosition="Top" 
                          AddingNewNodeCommand="{Binding AddingNewNodeCommand}"/>
    </dxg:GridControl.View>
</dxg:GridControl>
csharp
[Command]
public void AddingNewNode(NewNodeArgs args) {
    args.Item = new Product() {
        ProductName = "", 
        CompanyName = "New Company", 
        UnitPrice = 10, 
        Discontinued = false 
    };
}
vb
<Command>
Public Sub AddingNewNode(ByVal args As NewNodeArgs)
    args.Item = New Product() With {
        .ProductName = "",
        .CompanyName = "New Company",
        .UnitPrice = 10,
        .Discontinued = False
    }
End Sub

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.

See Also

AddingNewRowCommand

TreeListView Class

TreeListView Members

DevExpress.Xpf.Grid Namespace