Dynamically set property grid values
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
Attachment: EII.SF.PropertyGrid_e303750b.zip
Thanks for contacting Syncfusion support,
We have checked the reported issue that “Dynamically set the value” from our end. We have prepared the sample to achieve the requirement by using view model class. So you can check the sample from the below location for the reference and for more details. We have attached the Property Grid Documentation link below,
Sample: https://www.syncfusion.com/downloads/support/forum/170576/ze/Nested_Properties-483796181
Documentation: https://help.syncfusion.com/wpf/propertygrid/getting-started
Please check the above sample and let me know your concerns on this. If we are misunderstood your query, please provide the details for your requirement. So that we can provide a solution as earlier and it will be helpful for us.
Regards,
Sudharsan
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
Thanks for the update,
We have prepared the sample to achieve your requirement by populating the items in the Property Grid. So please find the sample from the below location,
Sample: https://www.syncfusion.com/downloads/support/forum/170576/ze/PropertyGridItemDefinition-1951913838
Please check with the above sample and let me know your concerns.
Regards,
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
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
Attachment: EII.SF.PropertyGrid_4ca53f9f.zip
Hi Aaron,
Thanks for the update,
Currently, we are analyzing your reported issue. We will validate and update you on the details on or before 06th December 2021.
Sudharsan
Thanks for the patience,
We have checked the reported issue that “Update Min/Max value for Int Property” from our end. We have prepared a sample to achieve the requirement by assigning the custom editor to Int properties to set the Min/Max value. So, please find the sample from the below location,
Sample: https://www.syncfusion.com/downloads/support/forum/170576/ze/EII.SF.PropertyGrid1976783611
Please check the sample and let me know whether the sample meets your requirement If not, please provide the details about the requirement for the further.
Regards,
Sudharsan
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
Thanks for the update,
We have checked the reported query “Set the min and max specified in the PropertyGridItem? from our end. We have prepared the sample to achieve the requirement by setting the parameters to custom editor for assigning the min/max value. So, please find the sample from the below,
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/EII.SF.PropertyGrid-MinMax-440595035
Please check the above sample and let me know your concerns. If you still facing any issue, please provide more details about the requirement.
Regards,
Sudharsan
- 10 Replies
- 2 Participants
-
AP Aaron Pedigo
- Nov 20, 2021 01:08 PM UTC
- Dec 8, 2021 02:55 AM UTC