【发布时间】:2012-07-26 09:13:15
【问题描述】:
我想要IValueConverter 中的特定格式并返回一个字符串。喜欢"MMMyyyy"我怎么才能得到这个?
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var item = (DateTime)value;
if (item != null)
{
return item.ToString();
}
return null;
}
【问题讨论】:
-
如果您在绑定中有日期时间对象,那么您可以使用绑定的字符串格式来获得您想要的输出
标签: c# ivalueconverter