如何使用带有集合的类对数据网格进行数据查询并相应地修改列 [英] How to databing datagrid with class with collection and modify columns accordingly
问题描述
我有以下课程:
public class MyDimension
{
public MyDimension()
{
obcItemsName = new ObservableCollection<string>();
obcItemsMeasured = new ObservableCollection<double>();
}
public string NameAxisDimension { get; set; }
public double Nominal { get; set; }
public double UpperTolerance { get; set; }
public double LowerTolerance { get; set; }
public ObservableCollection<string> obcItemsName;
public ObservableCollection<double> obcItemsMeasured;
}
及其实例存储在:
ObservableCollection< MyDimension> obcmMyDim =新的ObservableCollection< MyDimension>();
ObservableCollection<MyDimension> obcmMyDim = new ObservableCollection<MyDimension>();
我想使用它将数据绑定到数据网格
I would like to databind it to a datagrid with
dtgResults.ItemsSource = obcmMyDim
dtgResults.ItemsSource = obcmMyDim
这样数据网格的结果就是这样(用Excel制作)
so that the datagrid results like that (made with Excel)
其中PART11 PART20是存储在obcItemsName
集合中的名称,下面的值存储在obcItemsMeasured
集合中.
where PART11 PART20 are the names stored in the obcItemsName
collection and the values below are stored in the obcItemsMeasured
collection.
提前谢谢
推荐答案
您可以在此处找到一个很好的教程,以展示如何使用MVVM设计模式.
You can find here a good tutorial to show how you can work with MVVM design pattern MVVM TUTORIAL
这篇关于如何使用带有集合的类对数据网格进行数据查询并相应地修改列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!