首页 > 解决方案 > 如何将鼠标键绑定到 HoverTrack?

问题描述

我本质上想切换鼠标左右键。我想用左边平移,用右键查看系列值。将左键绑定到平移工作正常,但是当我尝试绑定鼠标右键以查看数据时出现问题 - 如果我单击它一次,除非光标离开 PlotView,否则数据不会消失。它表现得好像我拿着它,而实际上我不是。我在下面提供了一些基本代码:

var plotViewMain = new PlotView();
var controller = new PlotController();

controller.UnbindAll();
controller.BindMouseDown(OxyMouseButton.Left, OxyPlot.PlotCommands.PanAt);
controller.BindMouseDown(OxyMouseButton.Right, OxyPlot.PlotCommands.HoverTrack);
plotViewMain.Controller = controller;

标签: c#controlleroxyplot

解决方案


PlotCommands.HoverTrack只要鼠标悬停在点或轨迹上,就会显示数据。如果您希望仅在用户单击点或轨迹时显示数据点,您可能应该使用 PlotCommands.Track

controller.BindMouseDown(OxyMouseButton.Right, OxyPlot.PlotCommands.Track);

推荐阅读