I get this error when trying to have a WPF application try to format a string field as a datetime object:
<DataGridTextColumn Binding="{Binding Date, StringFormat={}{0:dd-MM-yyyy}}" Header="Date"/>
And the error I seem to be getting is:
"String was not recognized as a valid DateTime."
How do you fix this?
In my experience this error is caused by a lack of a set locale in the Window header, that is:
xml:lang="en-GB"
Or whatever is appropriate needs to be inserted into the Window header and that should fix the problem.