如何在WPF Grid中获取选定的列名称或索引

Abh*_*bhi 2 c# wpf xaml

您能告诉我如何在 WPF Grid 中获取选定的列名称或索引吗?

HCL*_*HCL 5

对于 DataGrid,您可以通过 CurrentCell 属性获取该列:

DataGridCellInfo cellInfo = dataGrid.CurrentCell;
DataGridColumn column=cellInfo.Column;
Run Code Online (Sandbox Code Playgroud)