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

Not possible to clean the content (RadMaskedNumericInput)

3 Answers 168 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Pablo
Top achievements
Rank 1
Pablo asked on 25 Mar 2011, 04:00 PM
Hello,

I am using a RadMaskNumericInput control, but I am not able to clean the value on the ViewModel. My set property is not hit when the user clicks the RadMaskNumericInput.ClearButton. 
I also tried to set the ClearCommand to an ICommand, but it is neither hit when the user clicks on the Clear button.
The only thing that happens when the clear button is clicked is that the text of the RadMaskNumericInput is cleaned, but not the value bound to it.
The version is the 2011 Q1
What I am doing wrong?

Thanks in advance,

This is the xaml:

            <telerik:RadMaskedNumericInput Grid.Column="1"
                                           VerticalAlignment="Center" HorizontalAlignment="Stretch"
                                           Mask="{Binding Path=Mask}"
                                           IsClearButtonVisible="True"
                                           AutoFillZeros="True"
                                           AutoFillNumberGroupSeparators="{Binding Path=IsNumber}"
                                           AllowSkipPlaceholders="False"
                                           Background="{Binding Path=IsValid, Converter={StaticResource boolToBackgroundConverter}, Mode=OneWay}">                <telerik:RadMaskedNumericInput.Value>
                    <Binding Path="Value"
                             Mode="TwoWay"
                             UpdateSourceTrigger="LostFocus"
                             NotifyOnValidationError="True"
                             ValidatesOnExceptions="True"
                             ValidatesOnDataErrors="True">
                    </Binding>
                </telerik:RadMaskedNumericInput.Value>
            </telerik:RadMaskedNumericInput>

3 Answers, 1 is accepted

Sort by
0
Alex Fidanov
Telerik team
answered on 28 Mar 2011, 09:38 AM
Hello Pablo,

This is because of the binding that you have applied. The UpdateSourceTrigger property of the Binding is set to LostFocus. The masked control will try to push the new value through the binding when the control loses focus. This is why the underlying value is not updated immediately after you press the clear button. If you want this you can use the PropertyChanged option for the UpdateSourceTrigger.

Kind regards,
Alex Fidanov
the Telerik team
0
Pablo
Top achievements
Rank 1
answered on 29 Mar 2011, 01:42 PM
Hi Alex,

I have found the problem. It was the mask used, using 'n' instead of '#', so the value was not updated until all the number of digits were typed.
Anyway, I found strange that the control cannot even be cleared by clicking on the button.

Thanks for your help,
Pablo
0
Alex Fidanov
Telerik team
answered on 29 Mar 2011, 03:46 PM
Hello Pablo,

This is because the 'n' token is a required one. If a required token is empty, the value will not be updated. You could use a non-required numeric token, like '#' and the value will be updated on each key stroke.

Greetings,
Alex Fidanov
the Telerik team
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Pablo
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Pablo
Top achievements
Rank 1
Share this question
or