I use oxyplot framework in wpf with MVVM pattern. And I want to change x-axis title, but I can not find any axis object. Axes property in PlotModel is empty. I find DefaultXaxis Property, and also it is null. How can I change default axis title without adding new Axes.
Thanks in Advance.
Take what I say with a bit of salt, but it might help anyone reading this.
It seems that the DefaultXaxis property is null only until everything has been initialized and bound, etc. This doesn't happen in say, the WPF's Window's cs-file's Partial Class constructor. But it seems to be assigned a value after the binding to PlotView happens.
If your goal is purely to add a title to DefaultXaxis property, I guess you can do it after the binding of the PlotModel to the PlotView. (At least I presume that's the event; in my case, a user control event method seems to be able to get a non-null value for DefaultAxis)objectOfClassThatCreatedPlotModel.plotModelObject.DefaultXAxis.Title = "test";
But if anyone's after just adding an X-Axis title immediately after creating an instance of the PlotModel (I am not sure why OP wants to avoid this), just use something like:
plotModelObject.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "x-title" })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With