21 lines
531 B
C#
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);
|
|
}
|
|
} |