XmlDocument PropertyGrid Binding

6 posts, 0 answers
  1. Joel Palmer
    Joel Palmer avatar
    175 posts
    Member since:
    May 2009

    Posted 17 Jan Link to this post

    Can I bind a PropertyGrid directory to an XmlDocument?  If not, does Telerik have any controls that gives me a nice GUI to edit the values in an XmlDocument?
  2. Joel Palmer
    Joel Palmer avatar
    175 posts
    Member since:
    May 2009

    Posted 17 Jan Link to this post

    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!

    Thanks, Joel

  3. Joel Palmer
    Joel Palmer avatar
    175 posts
    Member since:
    May 2009

    Posted 18 Jan Link to this post

    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:

        <LicenseServiceUrl>http://localhost/LicenseWcfService.svc<;/LicenseServiceUrl>
        <IsRun>true</IsRun>
        <WorkingDirectoryPath>C:\ProgramData\Prairie Grove\[Prairie Grove] Activity Log WcfService Host</WorkingDirectoryPath>
        <CustomerID>6EF684F0-78BB-4616-93B1-9B2D1EC8F275</CustomerID>
        <SystemID>528B5DEB-3093-4732-B5EC-D8B8C6F66782</SystemID>
        <TimerFrequency>600000</TimerFrequency>
        <LogLevelName>Debug</LogLevelName>
        <LogSettings>
            <Height xmlns="ActivityLogging.DD">300</Height>
            <Width xmlns="ActivityLogging.DD">600</Width>
            <LogLevelName xmlns="ActivityLogging.DD">Debug</LogLevelName>
            <LogSourceName xmlns="ActivityLogging.DD">FileSystem</LogSourceName>
            <DownloadCount xmlns="ActivityLogging.DD">100</DownloadCount>
            <DownloadStartDate xsi:nil="true" xmlns="ActivityLogging.DD" />
            <DownloadEndDate xsi:nil="true" xmlns="ActivityLogging.DD" />
            <CustomerID xmlns="ActivityLogging.DD">6EF684F0-78BB-4616-93B1-9B2D1EC8F275</CustomerID>
            <DirectoryList xmlns="ActivityLogging.DD" />
            <RootLogDirectoryPath xmlns="ActivityLogging.DD">C:\ProgramData\Prairie Grove</RootLogDirectoryPath>
            <LicenseServiceUrl xmlns="ActivityLogging.DD">http://localhost/LicenseWcfService.svc<;/LicenseServiceUrl>
            <IsSelectedHierarchyProduct xmlns="ActivityLogging.DD">false</IsSelectedHierarchyProduct>
            <FileSearchPattern xmlns="ActivityLogging.DD">*.xml | *.xml.zip</FileSearchPattern>
            <BackupPath xmlns="ActivityLogging.DD">C:\Temp</BackupPath>
            <DeleteOldDate xmlns="ActivityLogging.DD">2016-06-22T23:27:13.6069453-05:00</DeleteOldDate>
            <CompressOldDate xmlns="ActivityLogging.DD">2016-07-17T23:27:13.6089459-05:00</CompressOldDate>
            <CompressCategory xmlns="ActivityLogging.DD">Debug</CompressCategory>
            <CombineFileSize xmlns="ActivityLogging.DD">2000</CombineFileSize>
        </LogSettings>
    </AppSettings>

     

    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?

  4. Stefan X1
    Admin
    Stefan X1 avatar
    700 posts

    Posted 20 Jan Link to this post

    Hi Joel ,

    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.

    Best Regards,
    Stefan X1
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  5. Joel Palmer
    Joel Palmer avatar
    175 posts
    Member since:
    May 2009

    Posted 20 Jan Link to this post

    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)
      • Description
      • Display Name
      • etc

    Thanks in advance for your help,

    Joel

  6. Stefan X1
    Admin
    Stefan X1 avatar
    700 posts

    Posted 25 Jan Link to this post

    Hello Joel,

    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.

    Regards,
    Stefan X1
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top