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

Error while updating RadNumericUpDown

4 Answers 203 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
joshua odell
Top achievements
Rank 1
joshua odell asked on 19 Aug 2009, 08:45 PM
Hello, I've discovered an issue, and I'd like to see if this is some sort of desired behavior or a bug.  Here's the deal,  I've got a bunch of RadNumericUpDown controls, each lies within a UserControl.  and that UserControl is bould to an object. the RadNumericUpDown XAML looks like this.

        <telerik:RadNumericUpDown Grid.Column="1"  
                                  x:Name="inpPMax" Style="{StaticResource InputNumbers}" 
                                  ValueFormat="Numeric" NumberFormatInfo="{Binding Path=DisplayFormat}" 
                                  IsEnabled="{Binding Path=UserEntered}" 
                                  Minimum="{Binding Path=Minimum}" Maximum="{Binding Path=Maximum}" 
                                  SmallChange=".1" LargeChange="1" GotFocus="inpPMax_GotFocus" ValueChanged="inpPMax_ValueChanged"
            <telerik:RadNumericUpDown.Value> 
                <Binding Path="DisplayValue"  UpdateSourceTrigger="PropertyChanged" ValidatesOnDataErrors="True"/> 
            </telerik:RadNumericUpDown.Value> 
        </telerik:RadNumericUpDown> 
 

and the syle I'm using looks like this
            <Style x:Key="InputNumbers" TargetType="{x:Type telerik:RadNumericUpDown}"
                <Setter Property="Height" Value="25"/> 
                <Setter Property="FontSize" Value="12"/> 
                <Setter Property="Margin" Value="2"/> 
                <Setter Property="HorizontalContentAlignment" Value="Right"/> 
                <Style.Triggers> 
                    <Trigger Property="Validation.HasError" Value="true"
                        <Setter Property="ToolTip"  
                            Value="{Binding RelativeSource={RelativeSource Self},  
                                Path=(Validation.Errors)[0].ErrorContent}"/> 
                    </Trigger> 
                    <Trigger Property="Validation.HasError" Value="false"
                        <Setter Property="ToolTip" Value=""/> 
                    </Trigger> 
                </Style.Triggers> 
            </Style> 
 

The behavior I'm noticing is that when I enter "1000" in the text field, the control resets it back to 0, actually it looks like it sets it back to "000.000".  I thought that it might be doing this because I set the min and max values incorrectly, but when I debug into the "inpPMax_ValueChanged" method, I see that the control's max is set to double.maxvalue, and min is set to double.minvalue which means to me that it should't be failing this test.  I've also tried hard coding these values to 0.0, and 10000 respectively, with the same results.

I've noticed that if I enter 1999 (which is larget then (1000), the control resets the value to "999", to me it seems that the control is only taking the first 3 degits.  One other thing to note is that the binding for NumberFormatInfo looks like this.

        public NumberFormatInfo DisplayFormat 
        { 
            get 
            { 
                var ret = (NumberFormatInfo)CultureInfo.CurrentCulture.NumberFormat.Clone(); 
                ret.NumberDecimalDigits = DecimalPlaces
                return ret; 
            } 
        } 
        protected virtual int DecimalPlaces { get { return 0; } } 
 

This is because some "measurements" require 3 decimal places, while others require 0 and the control just binds to the "measurement"s DisplayFormat property.

it's going to be difficult to send any more code, but I'd greatly appreciate any help here, and I'll send whatever you ask for, if I can't get this to work I'll have to go back to a textbox, and I really don't want to do that.

4 Answers, 1 is accepted

Sort by
0
Accepted
Hristo Borisov
Telerik team
answered on 20 Aug 2009, 10:08 AM
Hello Joshua,

First of all, which version of the controls do you use? If you use our latest service pack, you can set the IsInteger property to true. This will ignore the values set from the NumberFormatInfo, and will format your RadNumericUpDown to show integer values. Moreover, you should update the instance of NumberFormatInfo that is already created in the RadNumericUpDown as it internally clones the current culture by default, instead of assigning it a complete new value.

For the input problem you shouldn't experience any problems if you are using our service pack version. If you still have problems, try setting the decimal separator from your language settings to dot, and tell us if the problem still exists. The reason I am asking you to change this value is because we have found a bug related to this, which we have already fixed and will be available for our internal build tomorrow.

Thank you for contacting and we look forward to receiving more feedback from your.

Regards,
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
joshua odell
Top achievements
Rank 1
answered on 20 Aug 2009, 05:09 PM
Hello Hristo 

I've updated to the SP version (0813), and I've noticed that my bindings do not work now.  I have a property called "DisplayValue" for the Value property of the control, I've changed it from a double to a double?, I checked this change against the earlier version (07??, I don't remember the exact number) and the bindings work just fine, but when i use the 0813 version the "set" of my property is never called.  
Is there some change in the way that these values are bound that I need to make?

please note that the read is working, if I hard code 100.0 to the getter of my DisplayValue property the UI does indeed set the control's display to 100.000, but when I make changes to the UI, either entering a new value with the number pad, or by using the arrows neither update is applied to the bound object's property.

THank you for your help

Josh
0
joshua odell
Top achievements
Rank 1
answered on 20 Aug 2009, 06:25 PM
I've done the following isolated test.  Ii created a new app, put a RadNumericUpDown in it, and databound it to a simple object, here's the code.

window1.xaml
<Window x:Class="WpfApplication2.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
   Title="Window1" Height="300" Width="300"
    <Grid> 
        <telerik:RadNumericUpDown x:Name="Rad" Value="{Binding Path=MyValue}"
             
        </telerik:RadNumericUpDown> 
    </Grid> 
</Window> 

window1.xaml.cs
namespace WpfApplication2 
    /// <summary> 
    /// Interaction logic for Window1.xaml 
    /// </summary> 
    public partial class Window1 : Window 
    { 
        public Window1() 
        { 
            InitializeComponent(); 
            Rad.DataContext = new Data(); 
        } 
    } 
 

Data.cs
namespace WpfApplication2 
    public class Data 
    { 
        private double _myValue; 
        public double MyValue 
        { 
            get 
            { 
                return _myValue; 
            } 
            set 
            { 
                _myValue = value
            } 
        } 
    } 
 

in this example, when the window is loaded the MyValue getter is called, but when I update the UI, using either the arrow keys, or the keyboard the settter is never called.  This leads me to believe that there is just a simple property on the UI that I'm not setting, but there aren't any databinding examples in the example application that is shipped.

Thanks again for the help.

Josh
0
Hristo Borisov
Telerik team
answered on 21 Aug 2009, 06:51 AM
Hello Joshua,

The problem comes from the way you set the binding expression. You are using a one way binding which is the default one, you should explicitly include Mode=TwoWay. For binding to data values you can check the data binding overview topic in our documentation that explains how to use the binding expressions in Silverlight.

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.
Tags
NumericUpDown
Asked by
joshua odell
Top achievements
Rank 1
Answers by
Hristo Borisov
Telerik team
joshua odell
Top achievements
Rank 1
Share this question
or