如何获取WPF数据网格中的所有选定单元格

man*_*der 1 c# wpf datagrid selection

我有一个WPF数据网格,我想获取网格中的所有选定单元格,我可以通过循环遍历所有项目来完成它,所以有没有内置的方法来做到这一点?

我在DataGrid中设置了两个属性:

SelectionMode="Extended"   // for multiple selection

SelectionUnit="Cell"    //row should not be selected but cell should be
Run Code Online (Sandbox Code Playgroud)

谢谢.

ice*_*bat 6

DataGrid具有SelectedCells属性.这是你在找什么?