We're using a WPF GridView that is dynamically bound to a DataTable (which in turn is the direct result of a DB query). This basically works fine and displays whatever the results from the DB query are in a nice table.
Now the problem is that some of the results contain DateTime columns, and the date displayed is always in US format and not in the user specified date format.
Is there an easy way to set the datetime formatting for the GridView display?
We don't know beforehand which columns will be DateTime as there are a number of different tables that are displayed.
The way we fill the gridview is as follows:
MyListView.DataContext = data;
MyListView.SetBinding(ListView.ItemsSourceProperty, new Binding());
MyGridView.Columns.Clear();
foreach (DataColumn col in data.Columns)
{
GridViewColumn gvcol = new GridViewColumn();
gvcol.Header = col.ColumnName;
gvcol.DisplayMemberBinding = new Binding(col.ColumnName);
MyGridView.Columns.Add(gvcol);
}