wpf grid and display dates

Nov 24, 2008 at 11:46 PM
I'm currently using the wpf datagrid with a dataset retrieved from a web serv ice. If I autogenerate the columns, it displays the date column, but formatted in us format. But would like to format it to uk format using the datagridtextcolumn method, I have seen examples of using stringformat for formatting the date field. But my date field with or without the stringformat will not display under the datagridtextcolumn method.

Any clues where I'm going wrong? The underlying data type is DateTime.


Nov 25, 2008 at 8:19 AM
Hi Mark,

You should be able to simple specify the StringFormat in the binding for this to work. Perhaps you could provide an example which shows the problem you are having.

I also have a small example of a DateTime column with formatting here:

Colin E.

Nov 25, 2008 at 1:56 PM

Hi Colin,

I was using your examples on codeproject to help me setup up the grid.
The following is the column declaration in window,xaml in the columns declaration:




<my:DataGridTextColumn Header="Last Trade" MinWidth="100" Binding="{Binding Last Trade, ConverterCulture='en-GB', StringFormat='{}{0:d}'}" />

I have autogeneratecolumns set to false.

However, it displays the date time field, if I autogenerate the columns. But it displays the date time in us format. Is this a bug in the grid?

Just got it working with UK dates on autogenerate by setting language="en-GB" in the datagrid declaration.

Thank you for your response.




Nov 25, 2008 at 2:08 PM
Hi Mark,

I vaguely recall reading somewhere that you manually have to specify the culture for DateTime binding formats:


Colin E.