[英]OxyPlot MouseEvents how to access PlotModel
鼠標事件將返回PlotController而不是plotView或plotModel。
我的問題是如何從鼠標事件中訪問plotModel? 有人可以告訴我從提供plotmodel作為源到現在提供plotcontroller的這種改變背后的想法嗎? 有人將這個plotcontroller作為源,如何根據鼠標事件選擇所有系列或放大?
我想添加一個由鼠標事件觸發的注釋。
var plott = new PlotModel();
plott.MouseDown += Plott_MouseDown;
public void Plott_MouseDown(object sender, OxyMouseDownEventArgs e)
{
var plot = sender as PlotController;
I NEED TO ACCESS THE PLOTMODEL TO ADD AN ANNOTATION
plot.Annotations.Add(new RectangleAnnotation(){ MinimumX = e.Position.X, MinimumY = e.Position.Y });
}
在xaml中為您的情節命名:
<oxy:PlotView x:Name="MyPlotView" .../>
從后面的代碼訪問它:
public void Plott_MouseDown(object sender, OxyMouseDownEventArgs e)
{
MyPlotView.Model.Annotations.Add(new RectangleAnnotation(){ MinimumX = e.Position.X, MinimumY = e.Position.Y });
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.