NumberFormatInfo in XAML

29 posts, 0 answers
  1. Mike Hanson
    Mike Hanson avatar
    25 posts
    Member since:
    Jul 2005

    Posted 31 Aug 2008 Link to this post

    Is it possible to set the NumberFormatInfo in XAML if so what is the syntax please.

    At this point I setting decimal places to 0 in code behind, but it would be preferable to set this in XAML

    Mike
  2. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 01 Sep 2008 Link to this post

    Hello Michael Hanson,

    At the moment, Silverlight XAML parser throws an exception when trying to create NumberFormatInfo in XAML. We reported this to Microsoft.

    When this is fixed, you will be able to set NumberFormatInfo in XAML in two ways:

    1. Create NumberFormatInfo in page resources and reference it as a static resource:

    <UserControl x:Class="SilverlightNumericTest.Page" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:globalization="clr-namespace:System.Globalization;assembly=mscorlib" 
        xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input">  
        <UserControl.Resources> 
            <globalization:NumberFormatInfo x:Key="numberFormatInfo" NumberDecimalDigits="0"/>  
        </UserControl.Resources> 
     
        <Grid x:Name="LayoutRoot" Background="White">  
            <telerikInput:RadNumericUpDown ValueFormat="Numeric" NumberFormatInfo="{StaticResource numberFormatInfo}"/>  
        </Grid> 
    </UserControl> 

    2. Create NumberFormatInfo and set it as an element value, like:

    <UserControl x:Class="SilverlightNumericTest.Page" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:globalization="clr-namespace:System.Globalization;assembly=mscorlib" 
        xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input">  
     
        <Grid x:Name="LayoutRoot" Background="White">  
            <telerikInput:RadNumericUpDown ValueFormat="Numeric">  
                <telerikInput:RadNumericUpDown.NumberFormatInfo> 
                    <globalization:NumberFormatInfo NumberDecimalDigits="0"/>  
                </telerikInput:RadNumericUpDown.NumberFormatInfo> 
            </telerikInput:RadNumericUpDown> 
        </Grid> 
    </UserControl> 


    Greetings,
    Hristo
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. SultanOfSuede
    SultanOfSuede avatar
    18 posts
    Member since:
    Jul 2007

    Posted 02 Dec 2008 Link to this post

    I have this code from Hristo's sample:

        <UserControl.Resources>
            <globalization:NumberFormatInfo x:Key="numberFormatInfo" NumberDecimalDigits="0"/>
        </UserControl.Resources>
       <telerik:RadNumericUpDown VerticalAlignment="Center" NumberFormatInfo="{StaticResource numberFormatInfo}"      x:Name="TextBoxMonthsFreeOutsideTerm" Height="25" Width="50" LargeChange="1" SmallChange="1" Minimum="0" Maximum="12" ValueFormat="Numeric" />

    This gives me AG_E_PARSER_BAD_TYPE at runtime.  If I remove the NumberFormatInfo property from the control, everything works.

    Are there plans to fix the bug anytime soon?
  4. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 03 Dec 2008 Link to this post

    Hello Ian,

    This is problem of Silverlight 2 XAML Parser. Not a RadNumericUpDown bug. So we will have to wait for the next Silverlight version and hope that this will be fixed.


    Sincerely yours,
    Hristo
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. SultanOfSuede
    SultanOfSuede avatar
    18 posts
    Member since:
    Jul 2007

    Posted 03 Dec 2008 Link to this post

    Thanks for your response Hristo.
  6. Dencil
    Dencil avatar
    6 posts
    Member since:
    Mar 2009

    Posted 25 Mar 2009 Link to this post

    hi telerik,

    is this issue fixed by microsoft?
    any updates available.

    regards,
    dencil.
  7. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 26 Mar 2009 Link to this post

    Hi Dencil,

    It is still not fixed, maybe it will be available in Silverlight 3 but I am not exactly sure. For the time being it can only be set through code.

    Regards,
    Boyan
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  8. Dencil
    Dencil avatar
    6 posts
    Member since:
    Mar 2009

    Posted 26 Mar 2009 Link to this post

    hi telerik,

    thank you for your prompt response.
    if it is possible through code, could you please suggest how it can be done.
    i tried the above examples but the xaml is throwing an error.
    i am using vs2008 and telerik wpf controls.

    please advice.

    regards,
    dencil.
  9. Ron
    Ron avatar
    15 posts
    Member since:
    Jan 2009

    Posted 29 Mar 2009 Link to this post

    I'm using Silverlight RadNumericUpDown and I managed to set the number of decimal digits to 0 by using this code:

                    System.Globalization.NumberFormatInfo objFormat = new System.Globalization.NumberFormatInfo();
                    objFormat.NumberDecimalDigits = 0;
                    numericIntUpDownFrom.NumberFormatInfo = objFormat;

    However, the arrows of this control don't work at all in this case.
    Any ideas?

    Thanks in advance
  10. Hristo Borisov
    Admin
    Hristo Borisov avatar
    298 posts

    Posted 31 Mar 2009 Link to this post

    Hi Ron,

    The NumberFormatInfo property is already instantiated and thus you don't have to assign new value to it, rather you should just change the

    numericIntUpDownFrom.NumberFormatInfo.NumberDecimalDigits = 0;

    value. If you still experience problems using the NumberFormatInfo please feel free to contact us.

    Kind regards,
    Hristo Borisov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  11. Ron
    Ron avatar
    15 posts
    Member since:
    Jan 2009

    Posted 31 Mar 2009 Link to this post

    I did what you suggested but the problem still exists.
  12. Hristo Borisov
    Admin
    Hristo Borisov avatar
    298 posts

    Posted 08 Apr 2009 Link to this post

    Hello Ron,

    I am really sorry for the late response. Would you make sure that you have set SmallIncrement to have value bigger than 1, so you can actually see that the value of the control is changing. In case it's set to 0.1 and you are rounding the value to 0 decimal places, there is no way you can anticipate any difference while clicking the arrows.

    Sincerely yours,
    Hristo Borisov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  13. Ron
    Ron avatar
    15 posts
    Member since:
    Jan 2009

    Posted 16 Apr 2009 Link to this post

    I found the problem.
    I have 2 RadNumericUpDown in my code and when I set NumberDecimalDigits = 0 to one of them and then set NumberDecimalDigits = 2 to the second control, the first control also presents 2 decimal digits.
  14. Ian
    Ian avatar
    51 posts
    Member since:
    Apr 2009

    Posted 03 May 2009 Link to this post

    I am having the exact same problems described here. As soon as you set the number of decimal places to zero the up/down arrows stop working.

    The reply above talks about SmallIncrement but there is no such property. Assuming this was meant to say SmallChange this makes no difference.

    I have a control on a page with the following style applied:

    <Style x:Key="NumericUpDownStyle" TargetType="tki:RadNumericUpDown">

     

    <Setter Property="IsEditable" Value="True" />

     

     

     

     

     

     

    <Setter Property="ValueFormat" Value="Currency" />

     

     

     

     

     

     

    <Setter Property="Minimum" Value="10000" />

     

     

     

     

     

     

    <Setter Property="Maximum" Value="999999999" />

     

     

     

     

    <Setter Property="MaxHeight" Value="20" />
     
    <Setter Property="VerticalAlignment" Value="Top" />

     

     

     

     

     

    </Style>

     

     

     

     

     

     

    The control itself is defined as follows:
    <tki:RadNumericUpDown Grid.Row="1" Grid.Column="5" x:Name="RetirementIncomeUpDown" SmallChange="5000" LargeChange="10000" Style="{StaticResource NumericUpDownStyle}">

     

     

     

     

     

     

     </tki:RadNumericUpDown>

     

     

     

     

     

     

     


    Code behind sets the number of decimal places to 0:

     

    var ud = (RadNumericUpDown)this.LayoutRoot.FindName("RetirementIncomeUpDown");

     

     

     

     

     

    if (ud != null)

     

     

           ud.NumberFormatInfo.CurrencyDecimalDigits = 0;

     

     

     

     


    If I remove the code behind that sets the number of decimal digits the arrows are still broken. If I amend the range of values to more closely resemble those shown in the demo the down arrow works fine but the up arrow only works if I start with a negative value and even then only works up to the point the value reaches 0 (despite a maximum value of 100 being specified as allowable)

    I'm very disappointed that what seemed like a fairly basic control (a) can't be initialised correctly in XAML to have no decimal places and (b) exhibits unpredictable behaviour when the arrow keys are used even when the decimal places are left to default to two places. 

    Are there any plans to supply fixes for these issues? On top of other issues (no documentation for some controls, limited functionality of the charting control, lack of support for anything other than images in the CoverFlow control etc) it is proving to be very hard to justify purchase of this set of controls once our trial evaluation period has expired, given our experience to date :-(
  15. Hristo Borisov
    Admin
    Hristo Borisov avatar
    298 posts

    Posted 03 May 2009 Link to this post

    Hi Ian,

    Unfortunately both of these problems are part of the Silverlight framework. Creating your own style and setting it to a multiple numeric controls is a good practice to the extent that you save code. Unfortunately, the RangeBase class provided by the Silverlight Framework seems to have some problems with its coercing of Minimum and Maximum values when set in Style. I managed to reproduce your scenario and I noticed that if I set the Maximum property before the Minimum in the Style, the control works fine. To further prove my logic that the problem comes from the RangeBase class I created the same Style but for another control that also uses RangeBase - RadSlider. Declaring the Minimum property setter prior to the Maximum yields the same result - the RadSlider doesn't response to changing its value. That is a pity as I tested the issue in the Silverlight 3 implementation of RangeBase which appears to have the same problem.

    What I would recommend is not to use Style, which will make your code a little bit more redundant, but will work correctly. For our next release we are planning to introduce our own RangeBase class that couples with generic types and hopefully doesn't introduce the same bugs as the Microsoft's one does. 

    Changing the NumberFormatInfo in xaml is still out of around hands. We will try to improve this formatting logic for our next release, and test whether an alternative one is required.

    We pretty much understand the problem of not having a complete documentation at the moment, considering the load of support we experience. Improving our documentation is our next strategic goal. We will focus on gradually improving our documentation and online examples in order to meet the desired quality standards. I am sure you understand the trade-off between top-notch functionality and comprehensive documentation that requires extensive up to date revisions.

    About the limitation of using only images in the CoverFlow. Silverlight 2, doesn't support perspective 3D transformation that will allow us to render any UI Element in perspective view. Fortunately, Silverlight 3 does support such transformation and the Silverlight team will stretch the framework capabilities to its maximum to deliver rich and reliable set of controls.

    What I can say is that all of your experience is limited to the Silverlight itself instead of our controls. Microsoft has several essential cornerstones to achieve which are coming very soon. I hope this will answer some of your concerns and will help you make your final say in purchasing our controls. Stay tuned for the upcoming releases and always feel free to contact us for further assistance.


    Greetings,
    Hristo Borisov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  16. Ian
    Ian avatar
    51 posts
    Member since:
    Apr 2009

    Posted 03 May 2009 Link to this post

    Thanks for the prompt response.

    Touch wood, your suggested workaround - removing any Style declaration for the control and specifying Maximum before Minimum appears to work.
     
    My frustration around documentation is compounded by the fact that the demos are often incomplete (or contain references to external files we don't have access to) and important controls are completely missing from the documentation so that there is only the demo to go by. In addition the documentation is extremely inconsistent eg One control will have a page describing the available events, another control won't.
  17. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 06 May 2009 Link to this post

    Hello Ian,

    As Hristo said we realize that our documentation is not as full and consistent as we want it to be. But we are trying to balance between new list of features and controls exceeding that of the competitors and because of this,  sometimes our documentation is suffering. We understand that in the moment this is our weakness but I assure you that we will do our best to reach the quality of documentation of our ASP.NET controls.

    Kind regards,
    Boyan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  18. Alexey Oyun
    Alexey Oyun avatar
    74 posts
    Member since:
    Mar 2010

    Posted 03 Jun 2010 Link to this post

    Hi, examples above fail with error:

    The type 'NumberFormatInfo' was not found because 'clr-namespace:System.Globalization;assembly=mscorlib' is an unknown namespace.

    Version 2010.1.422.1040

    Any ideas?

    Thanks, Alex.



  19. Daniel Billingsley
    Daniel Billingsley avatar
    95 posts
    Member since:
    Apr 2010

    Posted 07 Jun 2010 Link to this post

    Telerik:

    I really love most of your work, but sometimes I just don't understand.

    Just add something like the DecimalPlaces property on the Microsoft SL4 NumericUpDown and be done with it.  This is such a basic and expected feature of this control that I can't believe you didn't fix this a LONG time ago.
  20. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 09 Jun 2010 Link to this post

    Hi guys,

    I have added this request in PITS. You can view it here. You can vote for it, track its status and see when it is going to be implemented.

    If you have any other concerns about our controls please feel free to contact us again.

    Sincerely yours,
    Konstantina
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.
  21. Meik Schuetz
    Meik Schuetz avatar
    5 posts
    Member since:
    Sep 2009

    Posted 06 Jul 2010 Link to this post

    Do I understand this correctly? Almost two years have passed and I still cannot declare how many decimal digits the control should display in XAML? The problem might be Microsoft's Silverlight Framework, but in the meantime I'd offer my clients some kind of workaround...


  22. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 09 Jul 2010 Link to this post

    Hello Meik Schuetz,

    Thank you for contacting us.

    We will consider including such a property after the official release of Q2 2010, probably for the service pack due in few week after that. Hope this time frame is acceptable for you.

    If you have any other concerns about our controls please feel free to contact us again.

    All the best,
    Konstantina
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  23. Mike
    Mike avatar
    13 posts
    Member since:
    Jun 2011

    Posted 18 Oct 2011 Link to this post

    It looks like the issue is resolved and working now... but what about removing the comma from the number? Seems like the same problem persists, and I didn't see a property on RadNumericUpDown that may handle this.
  24. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 21 Oct 2011 Link to this post

    Hi Mike,

    Could you please specify which coma you want to remove. You can change all separators in the following way:
    numeric.NumberFormatInfo= new NumberFormatInfo();
    numeric.NumberFormatInfo.NumberDecimalSeparator = ".";
    numeric.NumberFormatInfo.NumberGroupSeparator = "";

    The second row changes the decimal separator and the third one removes the group separator. Hope this helps.

    Regards,
    Boyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  25. Mike
    Mike avatar
    13 posts
    Member since:
    Jun 2011

    Posted 21 Oct 2011 Link to this post

    Yes, that did work, but I was hoping to do this in XAML. Seems like adding a NumberDecimalSeparator on the RadGrid itself would be beneficial. I will add to PITS.
  26. Mike
    Mike avatar
    13 posts
    Member since:
    Jun 2011

    Posted 21 Oct 2011 Link to this post

    Sorry, I thought users could add requests to PITS. Can this request be added? Thanks!
  27. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 26 Oct 2011 Link to this post

    Hi Mike,

    I have added a feature request in PiTS. You can follow its progress here.

    Regards,
    Boyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  28. Matthew
    Matthew avatar
    33 posts
    Member since:
    Aug 2008

    Posted 16 Dec 2011 Link to this post

    Hi,

    It appears two issues were submitted into PITS for this, #2375 and #8314. The former is marked as resolved, but there are no details in PITS as to how to get to the new property or what version of code it was targeted for.

    How do we get to the feature that was resolved in #2375?

    Thanks, Matthew
  29. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 19 Dec 2011 Link to this post

    Hi Matthew,

    Issue 2375 is targetting just the NumberDecimalDigits and have a separate property-- NumberDecimalDigits that you can set in the XAML and that is why it is resolved. However you still can't set
    NumberFormatInfo in XAML hence you can't change the decimal separator and that is why issue 8314 is entered.

    Best wishes,
    Boyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top