seyounth.hyosung.ty/Seyounth.Hyosung.UI/Helpers/EnumBindingSourceExtension.cs
2025-04-07 23:25:45 +08:00

21 lines
531 B
C#

using System.Windows.Markup;
namespace Seyounth.Hyosung.UI.Helpers;
public class EnumBindingSourceExtension : MarkupExtension
{
public Type EnumType { get; private set; }
public EnumBindingSourceExtension(Type enumType)
{
if (enumType is null || !enumType.IsEnum)
throw new Exception("EnumType must be specified and be an Enum");
EnumType = enumType;
}
public override object? ProvideValue(IServiceProvider serviceProvider)
{
return Enum.GetValues(EnumType);
}
}