Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Create AxisDateTime at runtime

Solved!
Go to solution

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

0 Kudos
Message 1 of 3
(2,804 Views)
Solution
Accepted by topic author rizardus

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.)

~ Paul H
Message 2 of 3
(2,768 Views)

Thank you very much. 

0 Kudos
Message 3 of 3
(2,764 Views)