Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

ResourceTreeControl.Commands Property

Provides access to the set of available resource tree commands.

Namespace: DevExpress.Xpf.Scheduling

Assembly: DevExpress.Xpf.Scheduling.v24.2.dll

NuGet Package: DevExpress.Wpf.Scheduling

#Declaration

public ResourceTreeCommands Commands { get; set; }

#Property Value

Type Description
ResourceTreeCommands

A DevExpress.Xpf.Scheduling.ResourceTreeCommands object that provides a set of resource tree commands.

#Remarks

You can use the Commands property to programmatically execute a resource tree command.

The example below illustrates how to substitute the default DeleteCommand execution with a custom method defined in the ViewModel using the DXCommand binding tool.

             <dxsch:ResourceTreeControl Name="resourceTreeControl" Scheduler="{Binding ElementName=scheduler}">
                <dxsch:ResourceTreeControl.Commands >
                    <dxsch:ResourceTreeCommands DeleteCommand="{DXCommand Execute='MyDeleteCommand(@e(resourceTreeControl))'}" />
                </dxsch:ResourceTreeControl.Commands>
            </dxsch:ResourceTreeControl>
        public void MyDeleteCommand(DevExpress.Xpf.Scheduling.ResourceTreeControl resourceTree) {
            //obtain the handle of the row for which the menu has been invoked
            int selectedRowHandle = resourceTree.TreeList.GetSelectedNodes()[0].RowHandle;
            //check whether the menu has been invoked for a group row
            if (resourceTree.TreeView.GetNodeByRowHandle(selectedRowHandle).HasChildren) {
                //iterate through resources in the group and clear their Group property value
                TreeListNodeIterator nodeIterator = new TreeListNodeIterator(resourceTree.TreeList.GetSelectedNodes()[0].Nodes);
                while (nodeIterator.MoveNext())
                    (resourceTree.TreeList.GetRow(nodeIterator.Current.RowHandle) as ResourceItem).Group = null;
            }
            //remove the row for which the menu has been invoked
            resourceTree.TreeView.DeleteNode(selectedRowHandle);
        }
See Also