Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: Property Grid and Reflected PropertyInfo / FieldInfo

$
0
0
Hey,

I'm using the property grid and it works quite well, but I've run into a bit of a wall as I need to be able to display reflected Properties and Fields. I've been trying for a while to get it to work to no avail. I've tried things such as

-setting the selectedobject to an expando Object that represents a reflected property/field and nothing shows up

-setting the reflected and activated object, which only gave me a textbox with the name that I could edit

-Adding <xctk:PropertyDefinition Name="Properties"/> where Properties is
public PropertyInfo[] Properties { get; set; }
but of course it wants to give a collectionView which since they don't have a paramless constructor, crashes.

-Tried making a list<dynamic> Props which was populated like
public void GetPropertiesList()
        {
            var list = new List<dynamic>();

            foreach (var info in Properties)
            {
                dynamic properties = new ExpandoObject();
                var name = info.Name;
                properties.name = name;
                var value = info.GetValue(ReflectedDataObject);
                properties.value = value;
                 list.Add(properties);
            }
            Props = list;
        }
which when I click in the grid will pop up the collectionEditor but just have "ExpandoObject" and no properties in the collection PropertyGrid.

I have read some stuff about ICustomTypeDescriptor working but I'm not quite sure how to use it...

I'm wondering if I'm missing something big, small or if this is actually possible.. Help would be super appreciated.

Thanks,

Travis

Viewing all articles
Browse latest Browse all 4964

Trending Articles