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.
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.
Is it possible for you to send us an isolated sample project, where this is reproduced, so we could be able to investigate it further for you?
Hi Stephan, Sorry I could not recreate it as it is passing through two viewmodels and one webservice. I will have to spend more time to recreate it than solve. I could able to get the phoneNumber property value inside XamGrid CellExitingEditMode
private void XamGrid_CellExitingEditMode(object sender, Infragistics.Controls.Grids.ExitEditingCellEventArgs e) { CompanyPhoneNumbers newPhoneNumber = (CompanyPhoneNumbers)e.Cell.Row.Data; if (newPhoneNumber.PhoneNumber == "--") { // How to access maskeditor here to give the error message }}