I was already looking for stackoverflow for a solution and found this:
Need to format dates in dynamically generated WPF DataGrid
My problem is that I am loading some data from my SQL-Server database and want to show it in my WPF application in DataGrid. It works very well. The only thing I want to change is that the date column is in the format "DD / MM / YYYY HH: MM: SS" and I want to have "DD.MM.YYYY". Ok, then I looked at the link below and tried this in my program:
<Grid Width="648" Height="263"> <Grid.ColumnDefinitions> <ColumnDefinition Width="172*" /> <ColumnDefinition Width="90*" /> <ColumnDefinition Width="386*" /> </Grid.ColumnDefinitions> <DataGrid Name="dgBuchung" Height="213" HorizontalAlignment="Left" Margin="30,16,0,0" VerticalAlignment="Top" Width="595" AutoGenerateColumns="True" ItemsSource="{Binding}" Grid.ColumnSpan="3" Foreground="Black" BorderBrush="#FF688CAF" Opacity="1" Background="White" BorderThickness="1" > </DataGrid> </Grid>
The commented part is my solution, but it throws an XMLParseException. First of all, is such a solution possible when using AutoGenerateColumns? If not, how else can I try to handle this? If so, what is the problem with the code above?
EDIT: My question is not resolved because I decided not to rebuild my application, is there no solution with AutoGenerateColumns = true?
c # wpf datagrid date-formatting
Harald Nov 02 2018-11-11T00: 00Z
source share