Hello,
I have a list of items that I want put into a property grid. I have figured out how to set the name and category of each item in the property grid, but not the value.
Attached is a sample program showing my issue. I am trying to populate the property grid in ViewModel.
PopulatePropertyGrid. Could you please tell me what I need to do in order to populate the value?
Aaron
Sudharsan,
Unfortunately, this sample does not help my case.
In my case, I don't know the structure of the model at compile time.
That is why my Model class has generic properties that are for the
Syncfusion.Windows.PropertyGrid.PropertyGridItem.
Using this method, I was able to set the name and category, but not the value.
My overall goal is to populate the PropertyGrid with data which has a structure only known at run time.
I also want to be able to get the values from the PropertyGrid to save any changes that the user has made.
The important part is that the data structure is not known at compile time.
Aaron
Sudharsan,
This example still does not work for my scenario.
I cannot have a normal model class, because the property names are not known at run time.
This example still uses the model class to set the property values.
As you can see, the Model class in my example is based on the needs of the property grid, not the actual item being displayed in the property grid.
Is there a way to display data in a property grid when the properties are not known at compile time?
Aaron
|
public PropertyDescriptorCollection GetProperties()
{
List<CustomPropertyDescriptor> modelProperties = new List<CustomPropertyDescriptor>();
foreach (var model in models)
{
var attributes = new List<Attribute>();
if(!string.IsNullOrEmpty(model.Category))
{
var categoryAttribute = new CategoryAttribute(model.Category);
attributes.Add(categoryAttribute);
}
modelProperties.Add(new CustomPropertyDescriptor(this, model.ID, model.Value.GetType(), model.Name, attributes.ToArray()));
}
return new PropertyDescriptorCollection(modelProperties.ToArray());
} |
Sudharsan,
This helped me get a lot further but now I need a little bit more.
I put some example PropertyGridItems in the ViewModel.
How do I put a minimum and maximum on some (but not all) integer properties using this system?
Aaron
Sudharsan,
That is really close to what I need, but each of my properties can have their own min and max.
Is there a way to have the custom editor take in the min and max as parameters and the min and max specified in the PropertyGridItem?
Aaron