ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Editable DateTime axis

Hi,

 

I am trying to configure an editable DateTime axis in a graph using xaml. I have tried the following <ni:AxisDateTime Orientation="Horizontal" InteractionMode="EditRange"/>. However, druing runtime if I try to edit the time axis the values I enter is immediately discarded and the value is set back to default. When using eg. integer axis there is no issue. Am I doing something wrong with the time axis?

 

Brg.

 

Oddvar

0 Kudos
Message 1 of 3
(1,728 Views)

From “immediately discarded”, it sounds like the entered value failed to parse. To investigate the cause, I would suggest attaching a custom edit formatter that uses Parse instead of TryParse, so that you can examine any parse exceptions:

 

public sealed class CustomValueFormatter : GeneralValueFormatter {
    public override bool TryParse<TData>( string value, ValuePresenterArgs args, out TData parsedValue ) {
        parsedValue = base.Parse<TData>( value, args );
        return true;
    }
}

 

Here is how you can assign the custom formatter to your axis in XAML:

 

<ni:AxisDateTime Orientation="Horizontal" InteractionMode="EditRange">
    <ni:AxisDateTime.MajorDivisions>
        <ni:RangeLabeledDivisions>
            <ni:RangeLabeledDivisions.EditRangeValueFormatter>
                <local:CustomValueFormatter />
            </ni:RangeLabeledDivisions.EditRangeValueFormatter>
        </ni:RangeLabeledDivisions>
    </ni:AxisDateTime.MajorDivisions>
</ni:AxisDateTime>

 

 

~ Paul H
0 Kudos
Message 2 of 3
(1,696 Views)

Hi Paul,

 

Thanks! Works without any problems with the CustomValueFormatter. Thus I am not able to investigate what is going wrong in the first place. But as you said, definitely something with the parsing.

 

Oddvar

0 Kudos
Message 3 of 3
(1,653 Views)