wpf - OxyPlot 图表中的可绑定(bind)注释

标签 wpf xaml data-binding annotations oxyplot

我正在尝试使用 OxyPlot 来可视化时间序列,并且我正在使用注释来标记一些时间点和值级别,例如最小值/最大值等。

我想通过绑定(bind)在 WPF 中实现这一点,到目前为止,我从 Plot 开始。控制、两个轴和一个数据系列。这很好用,但我找不到将注释绑定(bind)到 ObservableCollection<Annontation> 的方法动态创建的各种注释。

<UserControl
    ...
    xmlns:oxy="http://oxyplot.org/wpf"
    ...
    >
    <Grid>
        ...
        <oxy:Plot>
            <oxy:Plot.Axes>
                <oxy:DateTimeAxis ... />
                <oxy:LinearAxis ... />
            </oxy:Plot.Axes>
            <oxy:Plot.Series>
                <oxy:StairStepSeries ... />
            </oxy:Plot.Series>
            <oxy:Plot.Annotations>
                <!--
                How do I bind to the ObservableCollection 'Annotations' in my ViewModel?
                Note, 'Annotations' property isn't available directly in Plot, either.
                -->
            </oxy:Plot.Annotations>
        </oxy:Plot>
    </Grid>
</UserControl>

最佳答案

我遇到了类似的问题。只是为其他人提供答案,如何使用 OxyPlot 处理这个问题:
如果您有未知数量的注释或系列,您应该使用

 <oxy:PlotView Model="{Binding PlotModel}" />
在 Xaml 和 ViewModel 上的这个属性
public PlotModel PlotModel { get; set; }
在此属性上,您具有更大的灵 active 。不能设置PlotModel.Annotations ,如 LineSeries.ItemSource ,但是您可以根据需要添加和删除每次如此多的注释。

关于wpf - OxyPlot 图表中的可绑定(bind)注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52971299/

相关文章:

C#/XAML winRT 应用导出 PDF

grails - 将请求参数绑定(bind)到过滤器中的域对象

jquery - Asp.Net MVC 2 带有集合的对象注册表单

Wpf ListView 分组

c# - 如何在 WPF 中从 mainwindow.xaml 导航到 page.xaml

c# - 标签可见性。折叠在空白内容WPF MVVM上

c# - 列表框、数据模板和触发器

c# - 从 WebBrowser 控件中加载的文档中获取标题

C# WPF 绑定(bind)行为

.net - 如何在执行 DataBind 之前对 DataSet 进行排序?