简体   繁体   English

如何在WPF DataGrid中获取所有选定的单元格

[英]How to get all the Selected Cells in WPF datagrid

I've a WPF datagrid, I want to get all the selected cells in the grid, I could do it by looping through all the items, so is there any built in way to do so? 我有一个WPF数据网格,我想获取网格中所有选定的单元格,我可以通过遍历所有项目来做到这一点,那么有没有内置的方法可以做到这一点?

I set two properties in DataGrid: 我在DataGrid中设置了两个属性:

SelectionMode="Extended"   // for multiple selection

SelectionUnit="Cell"    //row should not be selected but cell should be

Thanks. 谢谢。

DataGrid has SelectedCells property. DataGrid具有SelectedCells属性。 Is it what you`re looking for? 是您要寻找的东西吗?

I know that Grid.selecteditem works for row select; 我知道Grid.selecteditem适用于行选择; I would think it should work on cells too. 我认为它也应该适用于细胞。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM