public class ToPercentConverter : IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
decimal valuedecimal;
if (decimal.TryParse(value.ToString(), out valuedecimal))
return Math.Round(valuedecimal, 2).ToString("#0.00") + "%";
else
return "0.00%";
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return decimal.Parse(value.ToString().Replace("%", ""));
}
#endregion
}