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是绑定转换器时传过去的值。

posted @ 2018-04-02 23:01  致林  阅读(1138)  评论(0)    收藏  举报