OxyPlot中的多个LineSeries绑定

是否可以将绘图绑定到LineSeries集合而不是OxyPlot中的单个LineSeries? (而不是通过模型)。

我正在寻找这样的东西:

     

myCollectionOfLineSeries的位置是:

 private ObservableCollection _myCollectionOfLineSeries ; public ObservableCollection myCollectionOfLineSeries { get { return _myCollectionOfLineSeries ; } set { _myCollectionOfLineSeries = value; OnPropertyChanged("myCollectionOfLineSeries "); } } 

我希望得到答案:a)“不,这是不可能的”或b)“是的,只是在IJK之前放置XYZ”。

谢谢阅读。

可能有点晚了,但最近我有同样的问题:我需要动态绘制多个系列(基于用户选择的货币的几个收益率曲线)但我不想使用PlotModel直接绑定Plot ,因为其他属性(例如, Title )需要在我的View Model中设置为代码而不是XAML标记。

所以我将PlotModel定义为资源,将其绑定到Plot。 并在加载视图时查找PlotModel。 通过这种方法,我可以通过XAML标记定义可视内容(例如标题,轴,图例等),同时将逻辑放在我的视图模型代码中生成系列。

不确定这是否是一个好方法,但它解决了我的问题。

1)XAML – 定义资源

           

2)XAML – Plot

   

3)查看模型 – 从视图中获取模型但不绑定

 protected override void OnViewLoaded(object view) { base.OnViewLoaded(view); this._model = (PlotModel)((XXXView)view).FindResource("TestPlotModel"); } 

4)查看模型 – 生成多个系列

 _model.Series.Clear(); foreach (var currency in distinctCurrencies) { IEnumerable dataPoints = ...; LineSeries lineSeries = new LineSeries() { Title = String.Format("*{0}", currency), ItemsSource = dataPoints }; _model.Series.Add(lineSeries); } 

希望能帮助到你!

是的,看看他们的例子 ,你需要绑定到DataPoint的集合

 public ObservableCollection MyCollection { ... } 

    

Plot类型的Series属性没有setter:

 public Collection Series { get { return this.series; } } 

您可以绑定到Model属性,这是一个PlotModel类型,它具有带有getter和setter的Series集合属性。 有关更多详细信息,请查看SimpleDemo 。