Files
DP44/Common/DTS.Common/Converters/PercentConverter.cs
2026-04-17 14:55:32 -04:00

41 lines
1.7 KiB
C#

using System;
using System.Globalization;
using System.Windows.Data;
namespace DTS.Common.Converters
{
/// <summary>
/// Converter which converts percentage to String.
/// </summary>
public class PercentConverter : IValueConverter
{
/// <summary>
///
/// </summary>
/// <param name="value">The decimal value to convert. This value can be a standard decimal value or a nullable decimal value.</param>
/// <param name="targetType">This parameter is not used.</param>
/// <param name="parameter">This parameter is not used.</param>
/// <param name="culture">The culture to use in the format operation.</param>
/// <returns>The value to be passed to the target dependency property.</returns>
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);
}
/// <summary>
/// Conversion back is not supported.
/// </summary>
/// <param name="value">A currency value.</param>
/// <param name="targetType">This parameter is not used.</param>
/// <param name="parameter">This parameter is not used.</param>
/// <param name="culture">This parameter is not used.</param>
/// <returns>The value to be passed to the source object.</returns>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}