23 lines
573 B
C#
23 lines
573 B
C#
![]() |
using System;
|
||
|
using System.Windows.Markup;
|
||
|
using Avalonia.Markup.Xaml;
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
}
|