Localized decimal point character for NumericIndicator?

4 posts, 1 answers
  1. Mitchell
    Mitchell avatar
    45 posts
    Member since:
    Mar 2013

    Posted 13 Oct 2015 Link to this post

    An example: I have a NumericScale with a single NumericIndicator. I add 5 HexagonalNumberPosition instances to the indicator because I want to display the number "66.00". (Note: I have tried this with NumericIndicator.Format set to "F2" and ".00;.00;0" both - using the formatting described in the docs, not those exact strings). When English is the current cutlure, the gauge displays "66.00". When Spanish is the current culture, the gauge still displays "66.00". I would expect the decimal place to change with the culture. In this case is should be a comma. After peeking at the code in NumberTemplateSelector.SelectTemplate(), I created classes derived from HexagonalNumberPosition and NumberTemplateSelector just so I could break in NumberTemplateSelector.SelectTemplate(). The code (from Just Decompile) for SelectTemplate shows that a DataTemplate for each hex character is found by concatenating the digit (or symbol) passed in with ""HexagonalSevenSegs".  So, the digit "7" would result in the template with the key of "HexagonalSevenSegs7" being used. (The DataTemplates being located in the Telerik.Windows.Controls.DataVisualization.xaml" file). The problem seems to be that when Spanish is the current culture, the "." is still passed into SelectTemplate() for the decimal point. Even though there is a DataTemplate for the comma character, it is never utilized for the decimal point.  So, is the NumericIndicator ​supposed to display numbers using the current culture or a specific culture? Is it a bug that it is not doing so, or is this by design?

     

    Thanks - Mitch

  2. Mitchell
    Mitchell avatar
    45 posts
    Member since:
    Mar 2013

    Posted 15 Oct 2015 Link to this post

    I've created a support ticket for this question. I'll post the answer to my question when I receive it.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    Evgenia
    Admin
    Evgenia avatar
    1407 posts

    Posted 16 Oct 2015 Link to this post

    Hi Mitchell,

    I'm posting here the copy-pasted answer from your support ticket on the same topic for anyone else that comes upon this forum post.
    NumericIndicator supports setting different culture than the default one. You can easily set it to Spanish like this for example (let's say that the x:Name of the indicator is indicator in Xaml):

    this.indicator.Language = XmlLanguage.GetLanguage("es-ES");

    This will apply comma as separator to your 66 value in case you are using FontNumberPosition class to represent the appearance of characters in your numeric indicator. This will change the dot to comma separator automatically as the FontNumericPosition shows characters using regular fonts and they support localization.

    When using the HexagonalNumberPosition class however the approach is more complex. You pointed very correctly that we use TemplateSelector class to pick from a predefined number of templates the one that will represent the Hex number (x:Key = HexagonalSevenSegs0,HexagonalSevenSegs1 and etc. ), the Hex dot (x:Key = HexagonalSevenSegs. ) , the Hex comma (x:Key = HexagonalSevenSegs, ) or Hex dash (x:Key = HexagonalSevenSegs- ). And here comes the problem -- our comma data template is practically same as the one that represents dot and even though you might expect to see comma you will see dot instead. We apologize for this issue and will fix it for one of our upcoming latest internal builds.

    Till we fix the issue you might choose from two workaround approaches:
    1. Use FontNumberPosition only for the comma symbol:
    <telerik:NumericIndicator.Positions>
                             <telerik:HexagonalNumberPosition Background="#FFD6D4D4"  />
                             <telerik:HexagonalNumberPosition Background="#FFD6D4D4"  />
                             <telerik:FontNumberPosition Background="#FFD6D4D4" />
                             <telerik:HexagonalNumberPosition Background="#FFD6D4D4"  />
                             <telerik:HexagonalNumberPosition Background="#FFD6D4D4"  />
                         </telerik:NumericIndicator.Positions>

    2. I attached a custom project that demonstrates how you might create a custom HexagonalNumberPosition class where the ContentTemplate is your custom one.

    Let me know how these suggestions work for you.

    P.S. Please mind that we highly reccomend support threads over forums as the response time there is 24h and not 72h.  

    Regards,
    Evgenia
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. Mitchell
    Mitchell avatar
    45 posts
    Member since:
    Mar 2013

    Posted 16 Oct 2015 in reply to Evgenia Link to this post

    After setting the indicator Language property correctly, and using a FontNumberPosition for just the decimal place (with HexagonalNumberPositions for the other digits), my gauge looks great.  Thanks for the help! - Mitch

     PS - I've attached a screenshot of the mixed number positions final result.

     ​

Back to Top