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

Bind To Property

3 Answers 148 Views
MaskedInput
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 01 Oct 2018, 09:26 PM
How do you bind MaskedInput control to a viewmodel property?  I tried to bind to InputValue but I got a null reference error when I tried that.

3 Answers, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 02 Oct 2018, 03:03 PM
Hi David,

You're probably getting this error because the InputValue is being bound to a null string. Make sure the bound property is initialized with an empty string "" or use string.Empty.

Here's an example:

<telerikInput:RadMaskedInput
    InputValue="{Binding MyInputValue, Mode=TwoWay}"
    WatermarkText="Watermark"
    Mask="(CC) 00"
    MaskType="Text" />

public class ViewModel : ViewModelBase
{
    private string _myInputValue = "";
 
    public string MyInputValue
    {
        get => _myInputValue;
        set
        {
            if(_myInputValue == value)
                return;
 
            _myInputValue = value;
            OnPropertyChanged();
        }
    }
}

I've attached a demo, that also has a second Label to verify that the bound string is being updated when you type into the MaskedInput.

Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
David
Top achievements
Rank 1
answered on 02 Oct 2018, 03:16 PM

That worked. Thanks.

 

On mask input can you change the keyboard to "email"?

0
Lance | Manager Technical Support
Telerik team
answered on 02 Oct 2018, 03:34 PM
Hello David,

Currently, this is not possible. We do have this feature request on the backlog and it has been approved by the development team: MaskedInput: Add option for setting the virtual keyboard

If you'd like to increase its priority, please take a moment to up-vote it (click the like button). If you'd like to be notified of status changes (i.e. changing form Approved to Under Development), click the follow button.

Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
MaskedInput
Asked by
David
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
David
Top achievements
Rank 1
Share this question
or