ResourceTreeControl.Commands Property
Provides access to the set of available resource tree commands.
Namespace: DevExpress.Xpf.Scheduling
Assembly: DevExpress.Xpf.Scheduling.v24.1.dll
NuGet Package: DevExpress.Wpf.Scheduling
Declaration
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