作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对图表绑定(bind)有一点疑问。是否可以为 WPF 工具包折线图提供动态的系列数?
我找到了很多如何手动操作的示例。
例如,如果我有类似的东西:
<chartingToolkit:Chart Grid.ColumnSpan="4" Grid.Row="3" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" Name="chart_Distribution" Title="Chart Title">
模型如下:
public class Test : BaseViewModel
{
private readonly ObservableCollection<LineSeries> _lineSeries = new ObservableCollection<LineSeries>();
public ObservableCollection<LineSeries> LineSeries
{
get { return _lineSeries; }
}
private void Test()
{
var collection = new ObservableCollection<RequestsInProcess>();
var collection2 = new ObservableCollection<RequestsInProcess>();
collection.Add(new RequestsInProcess(0, 4));
collection.Add(new RequestsInProcess(1, 1));
collection.Add(new RequestsInProcess(2, 4));
collection.Add(new RequestsInProcess(3, 3));
collection2.Add(new RequestsInProcess(0, 3));
collection2.Add(new RequestsInProcess(1, 2));
collection2.Add(new RequestsInProcess(2, 2));
collection2.Add(new RequestsInProcess(3, 1));
var lineseries1 = new LineSeries();
lineseries1.IndependentValuePath = "AmountOfRequests";
lineseries1.DependentValuePath = "Time";
lineseries1.Title = "Line series1";
lineseries1.ItemsSource = collection;
Charts.Add(lineseries1);
var lineseries2 = new LineSeries();
lineseries2.IndependentValuePath = "AmountOfRequests";
lineseries2.DependentValuePath = "Time";
lineseries2.Title = "Line series2";
lineseries2.ItemsSource = collection2;
Charts.Add(lineseries2);
collection2.Add(new RequestsInProcess(4, 4));
collection.Add(new RequestsInProcess(4, 4));
}
}
如何将我的图表绑定(bind)到 ObservableCollection?可能吗?
最佳答案
在下面的博文中有一个很好的解决方案:
科林 E.
关于c# - 如何将 ObservableCollection<LineSeries> 绑定(bind)到图表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4488057/
我是一名优秀的程序员,十分优秀!