Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

ni:Plot Label string format

Hello,

I'm trying to format string for some of my plots using the standard WPF...

This does nothing:

<ni:Plot Label="{Binding Path=PlotLabels[0], StringFormat={}{0}g}"/>

And this way doesn't compile:

ContentStringFormat

 Please let me know if it's possible.

Thank you!

0 Kudos
Message 1 of 2
(2,497 Views)

It appears the issue is the binding StringFormat is only applied if the target property is string. The plot Label property type is object (following the WPF content model). If you use the same binding to set the text on a text block, it should evaluate with the string format.

 

To work around this, you could create a string format converter that will always call string.Format on the incoming value with a format string provided via the converter parameter, for example. Without writing any code, you could also try binding to an unused text property, and then binding that text property to the label.

~ Paul H
0 Kudos
Message 2 of 2
(2,460 Views)