views:

37

answers:

1

Hi All,

I am using WPF PropertyGrid (http://www.codeplex.com/wpg) in my project. But i have some problems with this component.

1) I can show my IList collections in a ComboBox. But i can't retrieve selected value. How can i get selected value?

2) Enums are automatically shown in combobox, but i can't retrieve selected value like #1.

Can you help me?

This is my collection property

public class Contact {
// Other properties

    [TypeConverter(typeof(MyConverter))]
        public string Cities
        {
            get;
            set;
        }
}

This is my converter class

class MyConverter : TypeConverter
    {
        public override bool
        GetStandardValuesSupported(ITypeDescriptorContext context)
        {
            return true;
        }
        public override StandardValuesCollection
        GetStandardValues(ITypeDescriptorContext context)
        {
            List<string> list = new List<string>();

            list.Add("Istanbul");
            list.Add("Ankara");
            list.Add("Izmir");

            StandardValuesCollection cols = new
            StandardValuesCollection(list);
            return cols;
        }
    }

When i set my Contact class's instance to WPF PropertyGrid's Instance property, i couldn't see any combox. But if i set my object to .Net PropertyGrid i can see this solution works well.

So i think this PG doesn't support TypeConverts, so what can i do?

A: 

Does WPF propertygrid support TypeConverters? The way it was done in Winforms PG was you could write a TypeConverter and add that as attribute to your property. The TypeConverter then could specify the StandardValuesCollection. So in your object you have property which takes one value and your converter specifies the collection of the possible values.

bjoshi
I added code samples to my code, can you take a look?
bahadir arslan
I checked now and i think it does not support TypeConverters :(
bahadir arslan