using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; namespace FurnaceUI.Converter { public class StringShowNameConvert : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) return value; string s = value.ToString(); int leng; if (s.Contains("\\")) { var temp = s.Split('\\'); s = temp[temp.Length - 1]; } if (int.TryParse(parameter.ToString(), out leng)) { if (s.Length <= leng) return s; else return s.Substring(0, leng) + "..."; } else return string.Empty; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } }