0

Customizing the bindings

Samuel Guedon hace 9 años actualizado hace 9 años 2
Hello,

First of all, keep up the good work, even if my poor C# skills make me look for hours for every little steps, Oxyplot seems to be the perfect fit for what I am trying to do.

I understand from the doc (http://docs.oxyplot.org/en/latest/controllers/index.html) that I can replace/delete the default mouse event and add new ones. My aim is to reaffect the Show 'Tracker' from left mouse to mous hover. The aim is to always see it as long as the pointer is on the graph.

So it seems pretty easy to unassign the left click with

myController.UnbindMouseDown(OxyMouseButton.Left);

But I can't get the syntax for AddHoverManipulator

myController.AddHoverManipulator(IView view, ManipulatorBase<OxyMouseEventArgs> manipulator, OxyMouseEventArgs args)

Basically i think I just get what view refers to (my PlotView control right? ==> this.PlotViewName)
Do I have to declare something before? What is a manipulator? What do I have to put for args?

Any help would be greatly appreciated.

Ciao
Actually it seems the code given in the documentation is not working. When I do

PlotController customController = new PlotController();
this.MainPlotView.Controller = customController;

The last line throw an exception




Ok so I found a possible solution, which in a way is better, but seems to raise a bug.

I understood that my issue came from the fact that I should use a new instance of a plot view, so I try to look at it differently mostly because I don't know how to instanciate a new plot view that would actually be the existing one - and keeping in mind that maybe I did not understood properly the issue. Anyway the solution seems better than my initial idea.

So I added a ControllerVM class in my View Model to host a new instance of a controller and bind it to the XAML.

It basically looks like this (lets forget for now my PlotModelVM class) :

public class VisualizerVM
{
public PlotModelVM PlotModelVM { get; set; }
public ControllerVM ControllerVM { get; set; }

public VisualizerVM()
{
this.PlotModelVM = new PlotModelVM();
this.ControllerVM = new ControllerVM();
}
}

public class ControllerVM
{
public ControllerVM()
{
this.Controller = new PlotController();
}
public PlotController Controller { get; private set; }
}

And here is my xaml

<oxy:PlotView Name="MainPlotView" Model="{Binding PlotModelVM.PlotModel}" Margin="0,29,0,0" Controller="{Binding ControllerVM.Controller}"/>

So now I can properly use UnbindMouseDown(OxyMouseButton.Left);

But I still dont understand how to reassign the Tracker to the mousehover event. Any ideas?