John Baird
Coatesville, Pennsylvanie, États-Unis
Information générale
Catégorie:
Windows Presentation Foundation (WPF)
Versions des environnements
>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
I would use a ValueConverter...
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement