3 changed files with 33 additions and 1 deletions
@ -0,0 +1,22 @@ |
|||
using System; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace BindingDemo |
|||
{ |
|||
public class EnumToEnumerable : MarkupExtension |
|||
{ |
|||
private readonly Type _enumType; |
|||
|
|||
public EnumToEnumerable(Type type) |
|||
{ |
|||
if (!type.IsEnum) |
|||
throw new ArgumentException(nameof(type)); |
|||
_enumType = type; |
|||
} |
|||
|
|||
public override object ProvideValue(IServiceProvider serviceProvider) |
|||
{ |
|||
return Enum.GetValues(_enumType); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue