Question about accessing the plot in MVVM

Oystein Bjorke 6 years ago 0
This discussion was imported from CodePlex

DrStrangeLove wrote at 2014-03-15 04:16:

My plot is created entirely in the view and is bound with data from the view model. When the data sets that are bound, my plot is not refreshing to redraw the data within the correct scale if I zoom or toggle the visibility of a line. So my question is how can I make sure that my graph resets to the correct size when I have zoomed or panned? If I press 'A' to reset the view before I switch the data binding the graph behaves correctly, it is just in the case when I do anything to the graph.

Any help is greatly appreciated and I hope I explained this question thoroughly.

DrStrangeLove wrote at 2014-03-26 17:56:

The real question I have is how can I access the plot that is entirely set up in the xaml, through my view model, because I need to refresh the plot when the data set changes so that they axises update correctly when the data changes.

tibel wrote at 2014-03-26 19:21:

Why you set up the plot in XAML when using MVVM?

objo wrote at 2014-03-26 20:25:

The Plot control has an InvalidatePlot method that can be called to invalidate and update the data.
There is also a command binding on the Plot.ResetAxesCommand command (I think this should be refactored to PlotCommands.ResetAxes)
You can also bind to the InvalidateFlag property - when the value is changed the plot is invalidated. I am not sure if this is a good feature, would like to get feedback on this one..
I think it is possible to use an attached property if you want to bind to the actual PlotModel.

objo wrote at 2014-03-26 20:35:

The command is changed to PlotCommands.ResetAxes. See example in the "ExportDemo".

DrStrangeLove wrote at 2014-03-27 15:06:

Thank you for the answer this was a big help.