05-02-2018 06:44 AM
I am trying to create following code at runtime after i deleted the old axis.
Snippet
<ni:AxisDateTime x:Name="xAxis" Orientation="Horizontal" Adjuster="ContinuousChart" Range="00:00:00, 00:00:20"> <ni:AxisDateTime.MajorDivisions> <ni:RangeLabeledDivisions LabelPresenter="mm:ss" /> </ni:AxisDateTime.MajorDivisions> </ni:AxisDateTime>
So far i tried like this
Snippet
AxisDateTime newAxis = new AxisDateTime(); newAxis.Orientation = Orientation.Horizontal; newAxis.Adjuster = RangeAdjuster.ContinuousChart; newAxis.MajorDivisions.LabelPresenter = "mm:ss";
The problem lies with setting the LabelPresenter. I got no clue how to set it.
Greetings
rizardus
Solved! Go to Solution.
05-04-2018 10:48 AM
LabelPresenter="mm:ss"
works in XAML because it uses a type converter to convert the string value to a ValuePresenter
. In this case, the result will be a GeneralValueFormatter
with the specified format string, which you can construct in code:
newAxis.MajorDivisions = new RangeLabeledDivisions { LabelPresenter = new GeneralValueFormatter("mm:ss") };
(Note that the default value for MajorDivisions
is a frozen object, so you need to create a new instance once to customize its properties.)
05-04-2018 10:55 AM
Thank you very much.