首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >不在LineSeries中的OxyPlot,点

不在LineSeries中的OxyPlot,点
EN

Stack Overflow用户
提问于 2014-01-26 21:05:31
回答 1查看 4.9K关注 0票数 3

我很难让OxyPlot在我的独立WPF应用程序中显示我的数据(我使用caliburn micro,并遵循MVVM模式)。

因此,在我的Xaml中,我有以下内容:

代码语言:javascript
运行
复制
<UserControl ...
xmlns:oxy="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf">

以及以后的

代码语言:javascript
运行
复制
<oxy:Plot Title="Winnings of Selected Player" Model="{Binding Graph1}"/>

在我的ViewModel中,我似乎可以选择包含using OxyPlot;using OxyPlot.Wpf;。如果我这样做,我可以定义我的PlotModel如下:

代码语言:javascript
运行
复制
private PlotModel _graph1;
public PlotModel Graph1 { 
    get { return _graph1;} 
    set { 
        _graph1 = value;
        Graph1.RefreshPlot(true);
    }
}

public MyViewModel() {

    Graph1 = new PlotModel();
    var FirstSeries = new LineSeries();
    FirstSeries.Points.Add(new DataPoint(1,2));
    FirstSeries.Points.Add(new DataPoint(1,2));

}

但是我的视图没有显示任何东西(事实上,我甚至没有在视图中看到“空图形”或标题)。我也尝试过将RefreshPlot命令散布到各处……

因此,我想尝试一下using OxyPlot.Wpf;。但是,我不能将Points添加到我的LineSeries中-这是我的IntelliSense的屏幕截图……

!(http://imageshack.com/a/img30/2441/cvqy.png)

那么,如何使用OxyPlot.Wpf将数据填充到我的LineSeries中呢?顺便说一句,我仍然看不到空图,即使我在编译时没有向LineSeries添加点。我看过的所有示例都是这样做的,或者它们在.xaml.cs代码隐藏文件中编写代码,这是我不想做的。

编辑:正如dellywheel提到的,当我问这个问题的时候,我忘了在上面的PlotModel中添加LineSeries,所以上面的构造函数应该包含下面这行。

代码语言:javascript
运行
复制
Graph1.Series.Add(FirstSeries);

但这只是在输入问题时,ofc不是真正的问题……

EN

回答 1

Stack Overflow用户

发布于 2014-01-26 21:28:48

您尚未将图表添加到图表中,并且图表是Graph1而不是图表尝试

代码语言:javascript
运行
复制
public MyViewModel(){
     Graph1 = new PlotModel();
     var firstSeries = new LineSeries();
     firstSeries.Points.Add(new DataPoint(1, 2));
     firstSeries.Points.Add(new DataPoint(1, 2));
     Graph1.Series.Add(firstSeries);
  }

希望这能有所帮助

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21363715

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档