Not possible to clean the content (RadMaskedNumericInput)

4 posts, 0 answers
  1. Pablo
    Pablo avatar
    5 posts
    Member since:
    May 2009

    Posted 25 Mar 2011 Link to this post

    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>

  2. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 28 Mar 2011 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Pablo
    Pablo avatar
    5 posts
    Member since:
    May 2009

    Posted 29 Mar 2011 Link to this post

    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
  5. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 29 Mar 2011 Link to this post

    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
Back to Top