Articles in this section

How to get a tree node in mouse double click event in WPF TreeGrid?

In WPF TreeGrid (SfTreeGrid) , you can get the TreeNode based on row and column index from the mouse pointer position. The TreeNode can be accessed by using any mouse events (example MouseDoubleClick event). This event is triggered when you double click on the TreeNode. Within this event, you can access the TreeGridPanel by using the GetTreePanel extension method that exists in the Syncfusion.UI.Xaml.TreeGrid.Helpers.

The row index of
TreeNode in the clicked position can be retrieved by resolving the mouse click position through TreeGridPanel.PointToCellRowColumnIndex. now, you can get the current TreeNode by passing the RowIndex in GetNodeAtRowIndex method in TreeGrid.
this.treeGrid.MouseDoubleClick += TreeGrid_MouseDoubleClick;
 
private void TreeGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
     var treeGridPanel = this.treeGrid.GetTreePanel();
     // get the row and column index based on the pointer position 
     var rowColumnIndex = treeGridPanel.PointToCellRowColumnIndex(e.GetPosition(treeGridPanel));
     if (rowColumnIndex.IsEmpty)
        return;
     var treeNodeAtRowIndex = treeGrid.GetNodeAtRowIndex(rowColumnIndex.RowIndex);                       
     MessageBox.Show("TreeNode : " + treeNodeAtRowIndex.ToString());
}

Shows mouse double clicked TreeNode details in SfTreeGrid

View sample in GitHub

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied