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

Cannot enter 0

3 Answers 58 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Scott Waye
Top achievements
Rank 2
Veteran
Iron
Scott Waye asked on 27 Feb 2013, 11:01 PM
Hi,

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"
                                                InputBehavior="Insert"
                                                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.

Thanks,

Scott

3 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 04 Mar 2013, 04:46 PM
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"
                                       HorizontalAlignment="Stretch"
                                       FormatString="{}{0:00}"
                                       InputBehavior="Insert"
                                       IsClearButtonVisible="False"
                                       Mask="#2"
                        maskedInput:MaskedInputExtensions.AllowNull="False"
                                       SelectionOnFocus="SelectAll"
                                       UpdateValueEvent="LostFocus" />

Where the "maskedInput" is defined like this:

xmlns:maskedInput="clr-namespace:Telerik.Windows.Controls.MaskedInput;assembly=Telerik.Windows.Controls.Input"

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.

0
Di
Top achievements
Rank 1
answered on 05 Jul 2013, 07:37 PM
Try this:
Mask="##" Placeholder=" "
0
Petar Mladenov
Telerik team
answered on 10 Jul 2013, 08:56 AM
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 ?

Regards,
Petar Mladenov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
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 >>
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Scott Waye
Top achievements
Rank 2
Veteran
Iron
Answers by
Pavel R. Pavlov
Telerik team
Di
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or