WPF转换器:时间转换为字符串

public object Convert(object value, Type targetType, object parameter,
                      System.Globalization.CultureInfo culture)
{
    if (value is DateTime)
    {
        DateTime test = (DateTime) value;
        string date = test.ToString("d/M/yyyy");
        return date;
    }

    return string.Empty;
}

parameter是绑定转换器时传过去的值。

原文地址:https://www.cnblogs.com/bincoding/p/8698554.html