This commit is contained in:
2020-02-28 21:32:32 +01:00
parent e6704c331f
commit 4293e60fa7
8 changed files with 17 additions and 1190 deletions

View File

@ -22,15 +22,16 @@ namespace ModernWpfPlayground.PropertyPresenter2
/// <summary>
/// Returns the content of a description attribute of an enum.
/// </summary>
/// <param name="enumValue"></param>
/// <param name="value"></param>
/// <returns></returns>
private static string GetDescription(object enumValue)
private static string GetDescription(object value)
{
if (!(value is Enum enumValue)) return string.Empty;
var descriptionAttribute = enumValue.GetType()
.GetField(enumValue.ToString()).GetCustomAttributes(false)
.OfType<DescriptionAttribute>().FirstOrDefault();
return descriptionAttribute?.Description ?? enumValue.ToString();
return descriptionAttribute?.Description ?? value.ToString();
}
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)