从wpf中的datagrid获取数据 [英] get data from datagrid in wpf

查看:1001
本文介绍了从wpf中的datagrid获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..
我正在wpf中使用datagrid,我想从datagrid中获取所有数据.
我该怎么办?
谢谢.

Hi..
i am using datagrid in wpf,i want to get all the data from datagrid.
how can i do this?
thanks.

推荐答案

获取所有数据"是什么意思?

数据网格中的数据可能会有一个潜在的源集合,可用于获取数据.
What do you mean by "get all the data"?

Data in the datagrid will probably have an underlying source collection which can be used to obtain data.


此处存在一种固有的误解,即应如何在数据网格中填充数据.您将要做的是在层次结构中的某个位置创建一个DataContext,网格将使用它作为绑定源. DataContext背后的数据可能会存储在ObservableCollection中,以便在从集合中添加/删除项目时更新网格(如果没有,则将在某个地方的IEnumerable列表中).使用此列表获取数据.
There is an inherent misunderstanding here of how the data should be populated in a datagrid. What you will have done is create a DataContext somewhere in the hierarchy which your grid will use as the source for its binding. The data behind the DataContext will probably be stored in an ObservableCollection so that the grid gets updated as items are added/removed from the collection (if not, it will be in an IEnumerable list somewhere). Use this list to get your data.


这篇关于从wpf中的datagrid获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆