1

I'm trying to have propertyGrid in Sukram WPF Diagram Designer Sample(WPF Diagram Designer - Part 4) and I'm Novice in wpf. How can I add Proper PropertyGrid in this project which I can show all properties of each Item in designer Canvas and also I can multi select the Items from designer canvas to show there common properties, and also I have custom property for each Item in designer. If every one has experience or has similar sample, please share with me. thank you

franssu
  • 2,422
  • 1
  • 20
  • 29
Ahad aghapour
  • 2,453
  • 1
  • 24
  • 33
  • Have a look at my answers in following threads - http://stackoverflow.com/questions/3800416/is-there-a-property-dialog-control-that-i-can-use-in-my-wpf-app/3801711#3801711 and http://stackoverflow.com/questions/4367051/to-those-who-uses-wpf-property-grid-wpg/4374258#4374258. – akjoshi Jan 09 '13 at 19:01
  • Thank you for good links – Ahad aghapour Feb 17 '13 at 08:36

1 Answers1

1

You can use windows PropertyGrid in you WPF application. you can create a class contain all properties you wanna show in propertygrid for example:

[TypeConverter(typeof(AllItemsTypeConverter))]   
public class AllItems
{

    public string Name
    {
        get { // }
        set { // }
    }

    public String description
    {
        get { // }
        set { // }
    }

}

there is a type convertor for AllItems Class you can filters your Items for each object you want like this:

  class AllItemsTypeConverter: ExpandableObjectConverter
    {

        public override PropertyDescriptorCollection GetProperties(
            ITypeDescriptorContext context, object value, Attribute[] attributes)
        {

            var originalProperties = base.GetProperties(context, value, attributes);
            var propertyDescriptorList = new List<PropertyDescriptor>(originalProperties.Count);

            foreach (PropertyDescriptor propertyDescriptor in originalProperties)
            {
                bool showPropertyDescriptor = true;
                switch (propertyDescriptor.Name)
                {
                    // this properties belong to Input
                    case "InputPlayInstance": showPropertyDescriptor = designerNode.ShowInput; break;
                    case "InputNodeInputSetup": showPropertyDescriptor = designerNode.ShowInput; break;
                    case "InputGrammerList": showPropertyDescriptor = designerNode.ShowInput; break;


.
.
.
.
                }

                if (showPropertyDescriptor) propertyDescriptorList.Add(propertyDescriptor);
            }


            return new PropertyDescriptorCollection(propertyDescriptorList.ToArray());
        }
    }

that class override the "GetProperties" method of "ExpandableObjectConverter" class you can specify that property to belong specific object or no.

Ahad aghapour
  • 2,453
  • 1
  • 24
  • 33