C# WPF DataGrid Contextmenu clicked column
I have simply Datagrid and context menu. I want to get information on what column of datagrid context menu appears. In WinWorms I found solution that MouseClick shows context menu manually and remember column
if (e.Button != MouseButtons.Right) return;
contextMenuStrip1.Show(dataGridView1, e.Location);
_ClickedColumn = dataGridView1.HitTest(e.X, e.Y).ColumnIndex;
How can I get column number in wpf datagrid?
Solution 1:
You can try the following to get the column index.
var index = dataGridName.CurrentColumn;