We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

SfMaskedEdit - Change mask dynamically

Hi,

I'm using a SfMaskedEdit control and trying to set the mask dynamically, I mean I have this mask (___) ___-____ for a phone number and I need to change the mask to this one (__) ____-____ at runtime when I press KeyUp, but what I'm getting when I write a phone number and change the mask is (122_123-1230. This is my code:

<syncfusion:SfMaskedEdit
                                x:Name="txtPhone"
                                Text="{Binding Customer.Telephone, Mode=TwoWay}" 
                                Mask="(000)000-0000" KeyUp="SfMaskedEdit_KeyUp"/>

private void SfMaskedEdit_KeyUp(object sender, KeyRoutedEventArgs e)
{
if (e.Key == Windows.System.VirtualKey.Up)
{
txtPhone.Mask = "(000)000-0000";
txtPhone.Value = "(___)___-____";
txtPhone.Text = "(___)___-____";
}
else if (e.Key == Windows.System.VirtualKey.Down)
{
txtPhone.Mask = "(00)0000-0000";
txtPhone.Value = "(__)____-____";
txtPhone.Text = "(__)____-____";
}
}

Is it a bug or what am I doing wrong?

Thank you.


1 Reply

VJ Victory Jessie Selvam D Syncfusion Team May 15, 2015 06:15 AM UTC

Hi Josel,

Thank you for using Syncfusion products.

We were able to reproduce the issue "Changing Mask property dynamically is not working" and have logged defect report regarding this. The fix for this issue will be included in our upcoming Service pack release which is scheduled in end of May, 2015.

Setting Mask property is enough to generate the expression and match the value in KeyUp event handler. Also kindly use the Value property to bound the input(instead of Text) in SfMaskedEdit control. Based on this we have modified your sample kindly download it from the following link:

Sample: MaskedEdit_DynamicMask.zip

Please let us know if you need further assistance on this.

Regards,
Jessie

Loader.
Live Chat Icon For mobile
Up arrow icon