Hello Kanniyappan Panneer Selvam!I appreciate the quick response and look forward to viewing the sample that is being prepared. I'm not sure if this is the correct way to go about this task, but perhaps this may serve you further in understanding what I'm trying to accomplish:In a viewmodel, I have made the following property, which I put as the propertyGrid.SelectedObject in my code behind of the xaml file: public PropertyBag Properties {get; set;}
T
he PropertyBag class implements a Dictionary(string, object) and the ICustomTypeDescriptor in the following way: ///
/// PropertyBagList contains the property bag and its contents.
///
public class PropertyBag : Dictionary-string, object-, ICustomTypeDescriptor
{
AttributeCollection ICustomTypeDescriptor.GetAttributes()
{
return new AttributeCollection(null);
}
string ICustomTypeDescriptor.GetClassName()
{
return null;
}
string ICustomTypeDescriptor.GetComponentName()
{
return null;
}
TypeConverter ICustomTypeDescriptor.GetConverter()
{
return null;
}
EventDescriptor ICustomTypeDescriptor.GetDefaultEvent()
{
return null;
}
PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty()
{
return null;
}
object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
{
return null;
}
EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
{
return new EventDescriptorCollection(null);
}
EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
{
return new EventDescriptorCollection(null);
}
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties()
{
return ((ICustomTypeDescriptor)this).GetProperties(null);
}
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
{
List
properties = new List();
//Add property descriptors for each entry in the dictionary
foreach (string key in this.Keys)
{
properties.Add(new PropertyBagPropertyDescriptor(key));
}
return new PropertyDescriptorCollection(properties.ToArray());
}
public object GetPropertyOwner(PropertyDescriptor pd)
{
return this;
}
}
And lastly, I have a PropertyBagPropertyDescriptor set up as such:
public class PropertyBagPropertyDescriptor : PropertyDescriptor
{
#region Constructor
///
/// Constructor - sets the Property Descriptor class and sets the key as the name.
///
///
The key to be set as the name of the descriptor.
public PropertyBagPropertyDescriptor(string key) : base(key, null) { }
#endregion
#region Properties
///
/// Gets the Property Type
///
public override Type PropertyType
{
get { return typeof(string); }
}
///
/// Gets whether it's read only
///
public override bool IsReadOnly
{
get { return false; }
}
public override bool IsBrowsable => true;
///
/// Gets the Component Type
///
public override Type ComponentType
{
get { return typeof(Dictionary); }
}
#endregion
#region Methods
///
/// Gets the value from the dictionary.
///
/// The value obtained from the dictionary.
public override object GetValue(object component)
{
return ((Dictionary)component)[base.Name];
}
///
/// Sets the value in the dictionary.
///
///
The value to be set in the dictionary.
public override void SetValue(object component, object value)
{
((Dictionary)component)[base.Name] = value;
}
///
/// Resets the value to empty string.
///
public override void ResetValue(object component)
{
((Dictionary)component)[base.Name] = null;
}
///
/// Gets whether value can be reset.
///
/// Boolean for whether it can be reset.
public override bool CanResetValue(object component)
{
return true;
}
///
/// Gets whether the value should be serialized.
///
/// Boolean for if the value should be serialized.
public override bool ShouldSerializeValue(object component)
{
return false;
}
#endregion
}
Let me know if there is any confusion, or any ways I can fix it based on what I currently have. When I debug and step through, the Dictionary is being loaded with the correct custom keys and values, but they are still not showing up in the SyncFusion PropertyGrid. I'm not sure if I am missing something that SyncFusion is looking for and thus, it is not displaying properly. Any help is appreciated.