using System; using System.Globalization; using System.Windows.Data; namespace DTS.Common.Converters { /// /// Converter which converts percentage to String. /// public class PercentConverter : IValueConverter { /// /// /// /// The decimal value to convert. This value can be a standard decimal value or a nullable decimal value. /// This parameter is not used. /// This parameter is not used. /// The culture to use in the format operation. /// The value to be passed to the target dependency property. public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var result = value as decimal? ?? 0; return String.Format(CultureInfo.CurrentUICulture, "{0:F1}%", result); } /// /// Conversion back is not supported. /// /// A currency value. /// This parameter is not used. /// This parameter is not used. /// This parameter is not used. /// The value to be passed to the source object. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } }