Torna al Thread
public class RatingToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
// Validate parameters
if (!(value is double))
{
throw new NotSupportedException("Unsupported value type in RatingToStringConverter.");
}
// Convert number to string
double doubleValue = Math.Floor((double)value);
if (0.0 == doubleValue)
{
return "Awful";
}
else if (1.0 == doubleValue)
{
return "Poor";
}
else if (2.0 == doubleValue)
{
return "Fair";
}
else if (3.0 == doubleValue)
{
return "Good";
}
else if (4.0 == doubleValue)
{
return "Great";
}
else
{
throw new ArgumentException("Unsupported value in RatingToStringConverter.");
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}