I have a XamMaskedEditor for phone number. When there is no number entered, it leaves back literals(--) in the TextBlock. With options of DisplayMode to Raw or IncludePromtChars, there is no change in the behavior. How to empty the textblock, if no number is typed?
Thanks in advance.
Hello Gayathri,
Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I handled the XamMaskedInput’s ValueChanged event and in the handler I change the Mask if there is value or not. Please let me know if this helps you or you have further questions on this matter.
Looking forward for your reply.
<ig:TemplateColumn.EditorTemplate>
<DataTemplate>
<ig:XamMaskedEditor Mask="999-999-9999CCCCCCCC" x:Name="xamMaskEditor" Value="{Binding PhoneNumber, Mode=Twoway}" AcceptsReturn="True" />
</DataTemplate>
</ig:TemplateColumn.EditorTemplate>
How do I access maskedEditor inside valuechanged event. Can you show me a sample code?. Thanks.
I am just checking if you got this worked out or you still require any assistance or clarification on the matter.
Thank you for checking Stephan, Actually the phone number is binded with a property called phonenumber. After the value changed event, it goes to a onpropertychanged event and assigns the same value again. This is a code written by someone and I am debugging it. So still looking for some work arounds in the present code.
Let me know if you have any ideas.
Without a sample project, I am not able to suggest you a possible solution or workaround for this. If it is possible for you to send me a sample project and more details about the result you want to achieve I will be glad to assist you further.
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
Hi,
Thanks for checking. I moved on to other defects, I still have this issue.
Following are code related to this.
In xaml
<ig:TemplateColumn Key="PhoneNumber" HeaderText="Phone Number" Width="*"> <ig:TemplateColumn.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding PhoneNumber}" /> </DataTemplate> </ig:TemplateColumn.ItemTemplate> <ig:TemplateColumn.EditorTemplate> <DataTemplate> <ig:XamMaskedEditor Mask="999-999-9999CCCCCCCC" Value="{Binding PhoneNumber, Mode=Twoway}" ValueChanged="XamMaskEditor_ValueChanged" AcceptsReturn="True"> </ig:XamMaskedEditor> </DataTemplate> </ig:TemplateColumn.EditorTemplate> </ig:TemplateColumn> </ig:XamGrid.Columns>
Code behind:
private void XamMaskEditor_ValueChanged(object sender, RoutedEventArgs e) { Infragistics.Controls.Editors.XamMaskedEditor xamEditor = (Infragistics.Controls.Editors.XamMaskedEditor)sender; if (xamEditor.Text == "___-___-____________") { xamEditor.ErrorMessage = "Phone Number is not in proper format."; } }
Viewmodel:
[DataMember] public string PhoneNumber { get { return _phoneNumber; } set { if (_phoneNumber != value) { _phoneNumber = value; OnPropertyChanged("PhoneNumber"); } } } private string _phoneNumber;
Did you try the approach I shared with you in my first response - changing the Mask in the ValueChanged event?
Yes. I did handle that event. But as I told you, after entering that event, it goes to the raisepropertychanged event for the phone number and allots the value. I have posted the code in the above post.