using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; namespace PDF_Master.DataConvert { public class GroupHeaderConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null || string.IsNullOrEmpty(value.ToString())) return null; if (value.ToString().Length == 8)//日期 { string dateStr = value.ToString(); string text = dateStr.Substring(0, 4) + "-" + dateStr.Substring(4, 2) + "-" + dateStr.Substring(6, 2); return text; } else//页码 { try { string page = "Page "; if ((int)value == -1) { return null; } else { return page + ((int)value + 1).ToString(); } } catch { return null; } } } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } }