然后对定义的枚举值添加上[Description]属性
namespace LocalizeFrameworkWpfApp { [TypeConverter(typeof(EnumDescriptionTypeConverter))] public enum Status { [Description("This is horrible")] Horrible, [Description("This is Bad")] Bad, [Description("This is SoSo")] SoSo, [Description("This is Good")] Good, [Description("This is Better")] Better, [Description("This is Best")] Best } }程序运行结果:
可以看到,我们添加了[Description]属性时,这两种方法都可以将[Description]属性的值绑定到指定控件中。
如果你觉得不错,扫描下面公众号给个关注,在此感谢!!