我需要将三个List添加到一个数据网格。每个列表应该有它自己的行。这些列表只会被创建/更改一次 - 这是在从CSV文件导入数据的过程中。我知道如何使用以下两个代码列表添加到DataGrid:将三个列表<string>添加到WPF数据网格
dtgCsvData.ItemsSource = time.Zip(temperature, (t, c) => new { time = t, temperature = c });
如果时间和温度是两个三个列表中。第三个也是最后一个列表被命名为rate。
public List<string> temperature;
public List<string> time;
public List<string> rate;
但是,我看不到我如何将最后一个列表添加到数据网格。我该怎么做?
如何将数据添加到TemperatureEntity类?现在我使用以下内容:'temperature = new List(reader.GetTemperature());' 'time = new List (reader.GetTime());' 'rate = new List (reader.GetRate ));' –
MikaelKP
@MikaelKP你的'读者'是什么?您需要创建'TemperatureEntity'的新实例并将其添加到列表中。 'temperature.Add(new TemperatureEntity(){Temperature = temperatureValue,Time = dateTime})' –