23 lines
717 B
C#
23 lines
717 B
C#
![]() |
using System.ComponentModel;
|
||
|
using System.Globalization;
|
||
|
using System.Reflection;
|
||
|
using System.Windows.Data;
|
||
|
|
||
|
namespace Seyounth.Hyosung.UI.Helpers;
|
||
|
|
||
|
public class EnumDescriptionConverter : IValueConverter
|
||
|
{
|
||
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||
|
{
|
||
|
if (value == null) return string.Empty;
|
||
|
|
||
|
var field = value.GetType().GetField(value.ToString());
|
||
|
var attr = field?.GetCustomAttribute<DescriptionAttribute>();
|
||
|
return attr?.Description ?? value.ToString();
|
||
|
}
|
||
|
|
||
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||
|
{
|
||
|
throw new NotImplementedException();
|
||
|
}
|
||
|
}
|