I have an XML FILE that I will like to bind to a WPF datagrid , I have successfully done that as below
The issue I have is that the date is not in the format I would like and is coming up as 1966/12/15 and i want this to be in 15/12/1966
I wrote a converter for this (Below)
Imports System.Windows.Data
Public Class DateTimeConverter Implements System.Windows.Data.IValueConverter
Public Function Convert(ByVal value As Object,
ByVal targetType As System.Type,
ByVal parameter As Object,
ByVal culture As System.Globalization.CultureInfo) _
As Object Implements System.Windows.Data.IValueConverter.Convert
Dim DateValue As DateTime = CType(value, DateTime)
Return DateValue.ToShortDateString
End Function
Public Function ConvertBack(ByVal value As Object,
ByVal targetType As System.Type,
ByVal parameter As Object,
ByVal culture As System.Globalization.CultureInfo) _
As Object Implements System.Windows.Data.IValueConverter.ConvertBack
Dim strValue As String = value
Dim resultDateTime As DateTime
If DateTime.TryParse(strValue, resultDateTime) Then
Return resultDateTime
End If
Return DependencyProperty.UnsetValue
End Function
End Class
and then tried using this in the XAML as below
</DataGridTextColumn.Binding>
</DataGridTextColumn>
But it throws an error saying it does not support converting from string .
can someone plese let me know what am doing wrong here .
Thanks