0

I'm trying to display XmlElement's attributes in Xceed PropertyGrid. For that purpose I defined custom wrapper class. It wraps XmlElement, iterates over XmlAttributes and creates custom PropertyDescriptor for each XmlAttribute. All "virtual" properties' type is String. All works fine. Now I want to have drop-down list of possible attribute values for every attribute that has restricted set of values. In Xceed's PropertyGrid, there is ItemsSourceAttribute for that. But it has to be applied as follows:

ItemsSourceAttribute(typeof(MyCustomItemsSource))

And here is the problem - I can not provide proper argument for MyCustomItemsSource constructor. What can I do about this?

It seems that there is another possibility - to define a TypeConverter, override GetStandardValues, and supply this converter to "virtual" property. But PropertyGrid just ignores this attribute.

How this simple task can be done with Xceed PropertyGrid?

Dmitry Arestov
  • 1,427
  • 12
  • 24

1 Answers1

0

Solved. I implemented custom editor

public class AttributeValuesEditor: Xceed.Wpf.Toolkit.PropertyGrid.Editors.ComboBoxEditor
{
    protected override IEnumerable CreateItemsSource(PropertyItem propertyItem)
    {
        var property = propertyItem.PropertyDescriptor as XmlAttributePropertyDescriptor;
        Debug.Assert(property!=null);
        return property.GetCompletionValues();
    }
}

Here, the context is passed into method in the form of PropertyItem. Now it is possible to differentiate between different attributes and return appropriate items.

Dmitry Arestov
  • 1,427
  • 12
  • 24