This is a migrated thread and some comments may be shown as answers.

NumberFormatInfo in XAML

28 Answers 605 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
Mike Hanson
Top achievements
Rank 1
Mike Hanson asked on 31 Aug 2008, 04:19 PM
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

28 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 01 Sep 2008, 02:19 PM
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.
0
SultanOfSuede
Top achievements
Rank 1
answered on 02 Dec 2008, 04:57 PM
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?
0
Hristo
Telerik team
answered on 03 Dec 2008, 07:36 AM
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.
0
SultanOfSuede
Top achievements
Rank 1
answered on 04 Dec 2008, 01:25 AM
Thanks for your response Hristo.
0
Dencil
Top achievements
Rank 1
answered on 26 Mar 2009, 02:17 AM
hi telerik,

is this issue fixed by microsoft?
any updates available.

regards,
dencil.
0
Boyan
Telerik team
answered on 26 Mar 2009, 09:44 AM
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.
0
Dencil
Top achievements
Rank 1
answered on 26 Mar 2009, 04:00 PM
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.
0
Ron
Top achievements
Rank 1
answered on 29 Mar 2009, 08:48 AM
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
0
Hristo Borisov
Telerik team
answered on 31 Mar 2009, 08:10 AM
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.
0
Ron
Top achievements
Rank 1
answered on 31 Mar 2009, 08:57 AM
I did what you suggested but the problem still exists.
0
Hristo Borisov
Telerik team
answered on 08 Apr 2009, 09:16 AM
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.
0
Ron
Top achievements
Rank 1
answered on 16 Apr 2009, 06:16 AM
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.
0
Ian
Top achievements
Rank 1
answered on 03 May 2009, 01:29 PM
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 :-(
0
Hristo Borisov
Telerik team
answered on 03 May 2009, 05:54 PM
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.
0
Ian
Top achievements
Rank 1
answered on 03 May 2009, 07:40 PM
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.
0
Boyan
Telerik team
answered on 06 May 2009, 07:52 AM
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.
0
Alexey Oyun
Top achievements
Rank 1
answered on 03 Jun 2010, 12:59 PM
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.



0
Daniel Billingsley
Top achievements
Rank 1
answered on 07 Jun 2010, 05:18 PM
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.
0
Konstantina
Telerik team
answered on 09 Jun 2010, 11:55 AM
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.
0
Meik Schuetz
Top achievements
Rank 1
answered on 06 Jul 2010, 03:44 PM
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...


0
Konstantina
Telerik team
answered on 09 Jul 2010, 08:36 AM
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
0
Mike
Top achievements
Rank 1
answered on 18 Oct 2011, 10:02 PM
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.
0
Boyan
Telerik team
answered on 21 Oct 2011, 08:19 AM
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 >>

0
Mike
Top achievements
Rank 1
answered on 21 Oct 2011, 02:48 PM
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.
0
Mike
Top achievements
Rank 1
answered on 21 Oct 2011, 02:50 PM
Sorry, I thought users could add requests to PITS. Can this request be added? Thanks!
0
Boyan
Telerik team
answered on 26 Oct 2011, 03:34 PM
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 >>

0
Matthew
Top achievements
Rank 1
answered on 16 Dec 2011, 04:13 PM
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
0
Boyan
Telerik team
answered on 19 Dec 2011, 10:50 AM
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 >>

Tags
NumericUpDown
Asked by
Mike Hanson
Top achievements
Rank 1
Answers by
Hristo
Telerik team
SultanOfSuede
Top achievements
Rank 1
Dencil
Top achievements
Rank 1
Boyan
Telerik team
Ron
Top achievements
Rank 1
Hristo Borisov
Telerik team
Ian
Top achievements
Rank 1
Alexey Oyun
Top achievements
Rank 1
Daniel Billingsley
Top achievements
Rank 1
Konstantina
Telerik team
Meik Schuetz
Top achievements
Rank 1
Mike
Top achievements
Rank 1
Matthew
Top achievements
Rank 1
Share this question
or