Question

I have Typeconverter for Enum:

 public class MyEnumConverter: TypeConverter
    {
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, Object value, Type destinationType)
        {
            //DO SOMETHING
        }
        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
        {
            //DO SOMETHING
        }
    }

If I put it over the property of the enum, it does not work.

        private MY_ENUM _myProp;
        [TypeConverter(typeof(MyEnumConverter))]
        public MY_ENUM MyProp
        {
            get { return _myProp; }
            set
            {
                if (_myProp != value)
                {
                    _myProp= value;
                    NotifyPropertyChanged("MyProp");
                }
            }
        }

Is it possible to put Typeconverter just over the Enum itself?

What do I do if I want that Converter will only work on a particular instance of the Enum?

Was it helpful?

Solution

In your case you shoud implement IValueConverter and use it in the binding expression for this particular property.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top