5 Answers, 1 is accepted
I did find an example but it has a very specifically formatted XML. I have XML generated using the XmlSerializer of an object. XmlSerializer outputs Nodes for each property.
So, to revise the question: Can I bind the PropertyGrid to an XML that was generated using the XmlSerializer from an object?
A working example would rock!
Well, I seem to be replying to my own post. It'd be nice if I had some feedback.
After looking at things, it seems my best option is to bind the Property Grid to the XML. This means I need to transform the XML generated by the XmlSerializer over to XML that the Grid can consume.
Do you have an example xsl document to do this? I assume you are already performing this behind the scenes.
Here is an example of my XML:
The next part of the challenge is... when I have the AppSettings object created from this XML, your grid is smart enough to not show certain entries based on their [System.ComponentModel.DataAnnotations.Display] property attributes. Do you have an XML attribute that communicates to the property grid not to display some of the properties (LogSettings) here?
From the provided information, I assume that you refer to the following forum thread: Binding XML to RadPropertyGrid, as you have posted a question in it as well. Speaking in general, there is nothing specific in the data binding mechanism of RadPropertyGrid, that would differentiate it from using an XML source in the framework as a whole. You need to convert the XML data to the needed objects and pass them to RadPropertyGrid as demonstrated in the aforementioned forum thread. You can refer to the Loading Data from XML topic from RadGridView's help for more information on the matter. It is not for the RadPropertyGrid component, but the approach would be basically the same.
As to your question regarding the nested properties not being displayed, I will need a little more time to research the case and will update you accordingly.
Telerik by Progress
Yes, you are correct in your reference to the "Binding XML to RadProperty Grid" post. So to recap, I have the following outstanding questions:
- Do you have an xsl document example that can convert xml from the XmlSerializer against an object (example provided) over to what the property grid requires that is demonstrated in the example posting?
- Exactly what XML attributes are required and what attributes are available to me in taking this approach?
- How do I define a drop-down list in the XML that allows the RadPropertyGrid to consume correctly.
- How do I communicate to the RadPropertyGrid to mimic its reactions to [System.ComponentModel.DataAnnotations]?
- Auto Generate (or not)
- Display Name
Thanks in advance for your help,
Thanks for the clarification.
I will try to address your questions one by one.
1. In order to deserialize an XML document with the XMLSerializer object, you can take a look at the Using XML common topic. You can also check out the Various Data Sources WPF demo and use a similar approach for using XML as a source for the control.
2. The control does not have logic for parsing XML attributes. Such operation must be handled manually.
3. I am afraid the answer for this question is the same as for the previous one. The control does not have logic for parsing and updating an XML source directly. This must be done manually, as shown in the resources I have referred to. If you need to edit a collection, you can check out the Collection Editors support of RadPropertyGrid.
4. The DataAnnotation s support of the control is documented in the Data Annotations topic. Can you please take a look at it?
I hope this clarifies your concerns. Feel free to approach me if further assistance is needed.
Telerik by Progress