RolloverDataTimeConverter.cs 918 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Data;
  6. using System.Windows.Media;
  7. using System.Windows;
  8. namespace Aitex.UI.Charting.Converter
  9. {
  10. public class RolloverDataTimeConverter : IValueConverter
  11. {
  12. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  13. {
  14. if (value != null)
  15. {
  16. DateTime dt;
  17. var isSucc = DateTime.TryParse(value.ToString(), out dt);
  18. if (isSucc)
  19. return string.Format("{0}{1}{2}", " 【", dt.ToString("yyyy/MM/dd HH:mm:ss"), "】 ");
  20. }
  21. return "N/A";
  22. }
  23. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  24. {
  25. return null;
  26. }
  27. }
  28. }