WPF Datagrid。获取所选行的每个单元格的值 [英] WPF Datagrid. Get the values of each cell of the selected row
本文介绍了WPF Datagrid。获取所选行的每个单元格的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用WPF工具包DataGrid。
I'm using the WPF toolkit DataGrid.
如何获取所选行的单元格的值?
How can I get the values of the cells of the selected rows?
推荐答案
在WPF中,行表示列表中的对象,而列则是对象的属性。
In WPF rows represent objects in a list and columns are object's properties.
这取决于什么DataGrid如果您的ItemSource是BindedClass的数组,则可以通过以下方式获取选定的对象:
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;
这篇关于WPF Datagrid。获取所选行的每个单元格的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文