I want to change is the date column from a format "DD/MM/YYYY HH:MM:SS" to "DD.MM.YYYY".
<DataGrid Name="dgBuchung" AutoGenerateColumns="True"
ItemsSource="{Binding}" Grid.ColumnSpan="3" >
<ab:DataGridTextColumn Header="Fecha Entrada" Width="110"
Binding="{Binding date, StringFormat={}{0:dd/MM/yyyy}}" IsReadOnly="True" />
</DataGrid>
Unfortunately that code throws an XMLParseException
.
First of all, is this way of solution possible while using AutoGenerateColumns? If no, how else can I try to handle this?
If yes, what is the problem with the code above?
Don`t forget to use DataGrid.Columns, all columns must be inside that collection. In my project I format date a little bit differently:
<tk:DataGrid>
<tk:DataGrid.Columns>
<tk:DataGridTextColumn Binding="{Binding StartDate, StringFormat=\{0:dd.MM.yy HH:mm:ss\}}" />
</tk:DataGrid.Columns>
</tk:DataGrid>
With AutoGenerateColumns you won`t be able to contol formatting as DataGird will add its own columns.