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

RadNumericUpDown does not fire propertychanged when empty

2 Answers 298 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 02 Sep 2016, 04:07 PM

Hi,

 

I encountered an issue with the RadNumericUpDown control. I have defined the UpdateValueEvent to PropertyChanged, this works fine as long as I am entering valid numeric values. But in case that I just delete the whole text from the NumericUpDown control the value is not updated in my viewmodel because the setter for the binded value is not called. When I leave the RadNumericUpDown afterwards the setter is called correctly and the value in my viewmodel is set to null.

This is my definition in XAML

<telerik:RadNumericUpDown Value="{Binding DurationFrom, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                ValueFormat="Numeric" NumberDecimalDigits="0" ShowButtons="True"
                Minimum="1" Maximum="{Binding DurationTo, Mode=OneWay, TargetNullValue=1.0}"
                NullValue="" UpdateValueEvent="PropertyChanged" />

 

Is this a known issue with the NumericUpDown control and is there any workaround for this?

Regards,

Micha

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Nasko
Telerik team
answered on 07 Sep 2016, 10:07 AM
Hello Michael,

We are already aware of the observed by you issue. It has been logged in our Feedback portal and you could vote for the item and track its status on the following link:
http://feedback.telerik.com/Project/143/Feedback/Details/185812-numericupdown-numericupdown-the-value-of-numericupdown-with-updatevalueevent-se

Until the issue gets fixed what we could suggest you is to handle the PreviewKeyDown event  of the NumericUpDown and explicitly set the value in its handler when the Backspace key is pressed. I have attached a sample project to demonstrate the approach, note that I have used our EventToCommandBehavior in order to handle the event in the ViewModel. Please download the attachment and give it a try.

If you have any additional questions or concerns regarding Telerik controls, please do not hesitate to contact us.

Regards,
Nasko
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Michael
Top achievements
Rank 1
answered on 07 Sep 2016, 10:11 AM

Thanks Nasko,

 

I amended your example a bit and figured out the following solution which works fine for me, maybe it helps others too.

 

private void NumericUpDownKeyUp(object sender, KeyEventArgs e)
        {
            if (e != null && sender != null && ((e as KeyEventArgs).Key == Key.Delete || (e as KeyEventArgs).Key == Key.Back))
            {
                if (string.IsNullOrEmpty((sender as RadNumericUpDown).ContentText))
                    (sender as RadNumericUpDown).Value = null;
            }
        }

Tags
NumericUpDown
Asked by
Michael
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Michael
Top achievements
Rank 1
Share this question
or