编程语言
首页 > 编程语言> > c# – wpf oxyplot – 单击datapoint时更改弹出窗口

c# – wpf oxyplot – 单击datapoint时更改弹出窗口

作者:互联网

我正在使用带有wpf的oxyplot,如果点击一个数据点,我想更改弹出窗口. OxyplotDataPointClick

有可能改变吗?我看了几个例子,展示了如何获得点击的点,但没有关于改变样式.

谢谢

解决方法:

该弹出窗口在OxyPlot的源代码中称为Tracker.
您可以通过OxyPlot.Wpf.PlotView.DefaultTrackerTemplate在XAML中定义其ControlTemplate:

<oxy:PlotView Model="{Binding SomePlotModel}">
  <oxy:PlotView.DefaultTrackerTemplate>
    <ControlTemplate>
       <!-- Put your content here-->
    </ControlTemplate>
   </oxy:PlotView.DefaultTrackerTemplate>
</oxy:PlotView>

如果每个系列数据需要不同的跟踪器,则使用OxyPlot.Wpf.PlotView.TrackerDefinitions.例如,如果您的LineSeries具有TrackerKey =“LineSeriesXyzTrackerKey”,则将其跟踪器定义为:

<oxy:PlotView Model="{Binding SomePlotModel}">
  <oxy:PlotView.TrackerDefinitions>
    <oxy:TrackerDefinition TrackerKey="LineSeriesXyzTrackerKey">
      <oxy:TrackerDefinition.TrackerTemplate>
        <ControlTemplate>
        <!-- Put your content here-->
        </ControlTemplate>
      </oxy:TrackerDefinition.TrackerTemplate>
    <oxy:TrackerDefinition TrackerKey="SomeOtherTrackerKey">
      <oxy:TrackerDefinition.TrackerTemplate>
        <ControlTemplate>
        <!-- Put your content here-->
        </ControlTemplate>
      </oxy:TrackerDefinition.TrackerTemplate>
  </oxy:TrackerDefinition>
</oxy:PlotView.TrackerDefinitions>

ControlTemplate的DataContext是TrackerHitResult,您可以在此处查看可用的属性:
https://github.com/oxyplot/oxyplot/blob/master/Source/OxyPlot/PlotController/Manipulators/TrackerHitResult.cs

一些例子:
How can I show the plot points in Oxyplot for a line Graph?
http://discussion.oxyplot.org/topics/592-wpf-tracker-multiple-value/

标签:c,wpf,oxyplot
来源: https://codeday.me/bug/20190608/1201295.html