Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8472797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:10:32+00:00 2026-06-10T17:10:32+00:00

I have an XML file with several child elements. Each child element contains a

  • 0

I have an XML file with several child elements. Each child element contains a series of elements, but the XML schema is undocumented, so I cannot possibly account for every possible element name. My goal is to provide an editor view for each child element. For example:

XML File

<root>
    <element>
        <subelement1>value</subelement>
        <randomName88787>value</randomName>
        <somethingTotallyFunky>value</somethingTotallyFunky>
        <iHaveNoIdeaWhatThisWillBe>value</iHaveNoIdeaWhatThisWillBe>
    </element>
</root>

I was hoping to use the WPF Toolkit’s PropertyGrid control (or something similar) to present a list of all child elements of <element>, but this control is designed to be bound to a CLR object. Of course I can’t define a class with properties because I don’t know what those properties will be. I’ve tried the following code to bind to an expando object:

var expando = new ExpandoObject();
var dict = (IDictionary<string, object>)expando;
foreach (var prop in unit.Elements())
{
    if (dict.ContainsKey(prop.Name.LocalName) == false)
    {
        dict.Add(prop.Name.LocalName, (string)prop.Value);
    }
}

Properties.SelectedObject = expando;

But no properties are displayed. It doesn’t seem to handle ExpandoObject very well. Is there a better way to approach what I’m trying to do? A better control to do it with?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:10:34+00:00Added an answer on June 10, 2026 at 5:10 pm

    Actually, you can do this without using any custom objects. Try this XAML with your example data in a file named data.xml:

    <Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <XmlDataProvider x:Key="data" Source="data.xml" XPath="/root/element/*"/>
    </Window.Resources>
    <Grid>
        <ListView ItemsSource="{Binding Source={StaticResource data}}">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Tag" Width="100">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Label Content="{Binding Path=Name}"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Value" Width="100">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding Path=InnerText}"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
    </Grid>
    </Window>
    

    I expect you’ll find any values that are changed by the user in XmlDataProvider.Document, so saving that should persist the user’s changes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several items in my xml file, but only one and the first
I have an XML file that contains several subTrees and those subtrees can also
I'm trying to have a script automatically transform an xml file into several html
i have an xml file Machine.xml it contains: <Parameter name=host value=localhost/> <Parameter name=port value=5900/>
Suppose i have a xml file which has several nodes & children. I am
In my layout xml file I have several buttons like this which share the
I have a class which reads an XML file to create several screens in
I have two sources: an xml-file containing definitions of several hundred data structures, basically
We have a source XML file that has an address node, and each node
I have several xml files, but I will present only one and the xsd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.