Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1770
Rounding values in field to certain number of decimal places
posted

hello. I can't figure out how to round double values in a field.

I have this style:

<Style x:Key="ThreeDecimalPlacesStyle" TargetType="{x:Type igWPF:XamNumericEditor}">
<Setter Property="Format" Value="{}{double:n.nnn}"></Setter>
</Style>

I want to round a particular column to say 3 decimal places but no matter what I do it's always to two decimal places.

What should there be in the Value or property Format for 3 decimal places?

  • 34810
    Verified Answer
    Offline posted

    Hello KrisVice,

    Thank you for your post.

    I'm not sure if I'm doing something wrong or not, but when I try to use a Format of "{}{double:n.nnn}" I get a rather strange result. However, by using a Format of "#.###," I am able to see my value with three decimal places. That is, unless the value ends in 0, as the default behavior will be to trim those. This can be avoided by setting the TrimFractionalZeros property to "False" though.

    Another thing that may be hindering you is the fact that you haven't set a Mask (to my knowledge). The default mask on the XamNumericEditor will be {}{double:9.2}, which will only ever allow two places to the right of the decimal point. I would recommend setting the Mask to "n.nnn" or "#.###" if you are looking to have three places to the right of the decimal point in edit mode.

    I have attached a sample project demonstrating the above. I hope this helps you.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer
    Infragistics Inc.
    www.infragistics.com/support

    XDGRoundingTest.zip