Cannot enter 0

4 posts, 0 answers
  1. Scott Waye
    Scott Waye avatar
    153 posts
    Member since:
    Nov 2009

    Posted 27 Feb 2013 Link to this post


    I am moving from MaskedTextBox to RadMaskedNumericInput, but have a problem.  My control represents minutes.  It is at most 99, minimum 0, always displays 2 digits so has leading 0s.  For 0 it displays 00, for 1 it displays 01, and for 12 it displays 12.  You should be able to set the value to 0 by typing 0 or  00, either is ok, but just 0 would be preferred.  Currently I have

            <Controls:RadMaskedTextBox x:Name="txtMinutes" Value="{Binding Minutes, ElementName=root,  Mode=TwoWay}"  UpdateValueEvent="LostFocus"
                                       IsReadOnly="{Binding ReadOnly, ElementName=root}"
                                       Mask="d2" MaskType="Numeric" Width="23" Grid.Column="4" BorderThickness="0" />

    Which is working ok.  So I tried to migrate to MaskedNumericInput, but I cannot find a combination of properties which work.  I currently have

                    <telerik:RadMaskedNumericInput  MinWidth="100" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                                        IsClearButtonVisible="False" Mask="#2"
                                                    Value="{Binding Hours, Mode=TwoWay}" Placeholder="0"
                                       FormatString="{}{0:00}"  BorderThickness="2"  SelectionOnFocus="SelectAll"
    And this is bound to a decimal property, but it will not accept 0, it just ignores it and displays an empty string on losing focus without pushing 0 back to the bound property.   Please advise setting that will replicate the behavior of the old MaskedTextBox.


  2. Pavel R. Pavlov
    Pavel R. Pavlov avatar
    1237 posts

    Posted 04 Mar 2013 Link to this post

    Hi Scott,

    I am not sure that I understand your scenario. Can you please elaborate on what you expect to see when you enter 0 and why you need to set the placeholder to 0? In your case you set the placeholder to a valid value and this is why the control does not update its value when you type 0 (zero).

    Keep in mind that if you leave the placeholder to its default value and you set the attached property AllowNull to False, the control will update its value when you enter 0. this can be done by the following code:

    <telerik:RadMaskedNumericInput x:Name="input"
                                           UpdateValueEvent="LostFocus" />

    Where the "maskedInput" is defined like this:


    Let me know if you need further assistance.

    Kind regards,
    Pavel R. Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Di
    Di avatar
    16 posts
    Member since:
    Jul 2013

    Posted 05 Jul 2013 Link to this post

    Try this:
    Mask="##" Placeholder=" "
  4. Petar Mladenov
    Petar Mladenov avatar
    2991 posts

    Posted 10 Jul 2013 Link to this post

    Hello Di,

    Could you please elaborate on your sceanario? Is there some unwanted behavior that you have reproduced with these settings? Is it possible for you to let us know the exact steps you perform and what is the desired result ?

    Petar Mladenov
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top