我正在尝试使用 wpf 工具包图表线,并且我需要在图表中有不止一条线,但我不知道该怎么做在 c# 中动态执行。在程序中,我不知道我需要多少图表以及每个图表中有多少行,这是我在 XAML 中无法做到的...
for (int j = 0; j < 4; j++) //its just so i cant check it
{
ColumnDefinition cd = new ColumnDefinition();
myGrid.ColumnDefinitions.Add(cd);
Chart chart1 = new Chart();
LineSeries lineChart = new LineSeries();
chart1.Height = 200;
chart1.Width = 300;
chart1.Title = (j);
//((LineSeries)chart1.Series[0]).ItemsSource = valueList;
lineChart.DependentValuePath = "Value";
lineChart.IndependentValuePath = "Key";
lineChart.ItemsSource = valueList;
lineChart.IsSelectionEnabled = true;
chart1.Series.Add(lineChart);
lineChart.ItemsSource = valueList1;
chart1.Series.Add(lineChart); <---
myGrid.Children.Add(chart1);
Grid.SetColumn(chart1, (j));
Grid.SetRow(chart1, 0);
}
我试过这个,但它不工作......
请帮忙!:(