4 using System.Globalization;
6 namespace SiliconStudio.Presentation.ValueConverters
13 public class TrimString : OneWayValueConverter<TrimString>
16 public override object Convert(
object value, Type targetType,
object parameter, CultureInfo culture)
22 length = System.Convert.ToInt32(parameter);
27 throw new FormatException(
"The parameter must be convertible to a non-null integer.");
33 bool addEllipsis = length >= 0;
34 length = Math.Abs(length);
35 var str = value.ToString();
37 return str.Length > length ? str.Substring(0, length) + (addEllipsis ?
"..." :
"") : str;
override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
This converter will trim the string representation of an object to the given number of characters...