Articles in this section

How to expand or collapse the WPF TreeGrid (SfTreeGrid) by clicking any cell in the row?

You can expand or collapse the groups by click any cell in row by overriding ProcessOnTapped method in TreeGridRowSelectionController of WPF TreeGrid (SfTreeGrid).

treeGrid.SelectionController = new TreeGridSelectionControllerExt(treeGrid);

public class TreeGridSelectionControllerExt : TreeGridRowSelectionController
{
    public TreeGridSelectionControllerExt(SfTreeGrid treeGrid) : base(treeGrid)
    {
    }

    protected override void ProcessOnTapped(MouseButtonEventArgs e, RowColumnIndex currentRowColumnIndex)
    {
        if (currentRowColumnIndex.RowIndex <= this.TreeGrid.GetHeaderIndex())
            return;

        var node = TreeGrid.GetNodeAtRowIndex(currentRowColumnIndex.RowIndex);
        if (node != null)
        {
            if (node.IsExpanded)
                TreeGrid.CollapseNode(node);
            else if (!node.IsExpanded)
                TreeGrid.ExpandNode(node);
        }

        base.ProcessOnTapped(e, currentRowColumnIndex);
    }
}

Demo to show expand and collapse by click any cell

View Sample in GitHub.

Conclusion
I hope you enjoyed learning about how to expand or collapse the WPF TreeGrid (SfTreeGrid) by clicking any cell in the row.
You can refer to our WPF TreeGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied