Use a ValueConverter:
public class EmptyDateCoverter: IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if(value is DateTime)
{
if((DateTime)value == DateTime.MinValue)
{
return "";
}
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
//We don't need convert back
throw new NotImplementedException();
}
}
Create a resource for the converter for example in the control's resources (conv is the alias for the namespace where the converter is defined )
<conv:EmptyDateCoverter x:Key="EmptyDate" />
and then apply the binding in this way:
<GridViewColumn x:Name="DataGridLastEdit" Header="Last Edit" Width="150px" DisplayMemberBinding="{Binding lastEdit, Converter={StaticResource EmptyDate}}" />