WPF Datagrid. Get the values of each cell of the selected row

a 夏天 提交于 2019-12-13 15:12:55

问题


I'm using the WPF toolkit DataGrid.

How can I get the values of the cells of the selected rows?


回答1:


In WPF rows represent objects in a list and columns are object's properties.

It depends on what DataGrid.ItemsSource is.If your ItemSource is an array of BindedClass you could get selected object by:

BoundClass bc = (BoundClass)dataGridControl.SelectedItem;
var prop1 = bc.Prop1;
var prop2 = bc.Prop2;


来源:https://stackoverflow.com/questions/1570929/wpf-datagrid-get-the-values-of-each-cell-of-the-selected-row

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!