General information
Category:
Windows Presentation Foundation (WPF)
Title:
How to Mask Phone number in textbox
I have a WPF Window with a DataGrid. This DataGrid contains a phone number column. The phone number is stored as a string without any formatting such as "9995551234".
How can I display the phone number column with the following format? (999)555-1234
Here is the phone column of my DataGrid with the format that I have tried but this does not work.
DataGridTemplateColumn Header="Phone" Width="100"
DataGridTemplateColumn.CellTemplate
DataTemplate
TextBlock Text="{Binding PhoneNumber, StringFormat={}{0:(###)###-####}}" Width="100"
DataTemplate
DataGridTemplateColumn.CellTemplate
DataGridTemplateColumn.CellEditingTemplate
DataTemplate
TextBox Text="{Binding PhoneNumber, StringFormat={}{0:(###)###-####}}" Width="100"
DataTemplate
DataGridTemplateColumn.CellEditingTemplate
DataGridTemplateColumn
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only