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 4093826
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:40:01+00:00 2026-05-20T19:40:01+00:00

I am reading up more on XAML and I have created an XML file

  • 0

I am reading up more on XAML and I have created an XML file and want to load it. It all works but when I use the ContentProperty attribute and more importantly I remove the Company.Employees tags from the XML file, I get the error “cannot add to Company” when loading the xml file.

The code is :

<?xml version="1.0" encoding="utf-8" ?>
 <Company Name="BBC" xmlns="clr-namespace:XamlLoading;assembly=XamlLoading">
  <Company.Owner> 
    <Person Name="John" Age="49"/>
  </Company.Owner>

  <!--<Company.Employees>
    <Person Name="Dave" Age="66" />
     <Person Name="Paul" Age="45"/>
  </Company.Employees>-->

 <Person Name="Dave" Age="66" />
 <Person Name="Paul" Age="45"/>
</Company>
[ContentProperty("Employees")]
public class Company 
{
    public Company()
    {
        Employees = new List<Person>();
    }

    public Person Owner { get; set; }

    public string Name { get; set; }
    public List<Person> Employees { get; set; }
}


    static void Main(string[] args)
    {
        using (FileStream fs = File.OpenRead(@"..\..\company.xml"))
        {

            Company c = (Company)XamlReader.Load(fs); * ERROR HERE

            Console.WriteLine(c.Name);
            Console.WriteLine(c.Owner);

            foreach (var item in c.Employees)
            {
                Console.WriteLine("{0} : ", item);
            }

            Console.ReadLine();
        }
    }
  • 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-05-20T19:40:01+00:00Added an answer on May 20, 2026 at 7:40 pm

    I would suggest that you update to the latest version of .NET. Your code works great for me.

    This is a very interesting case study for XAML. I have never seen it used this way before. Typically XAML is used like HTML markup for declaratively defining a user interface. Blend is a WYSIWYG editor for creating user interfaces by generating XAML.

    You have demonstrated some interesting potential for realizing data from xml using the XamlReader.

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

Sidebar

Related Questions

Reading through more SICP and I'm stuck on exercise 1.3.8 . My code works
I've been reading/learning more about Spring lately, and how one would use Spring in
Recently I have been reading more and more about people using custom attributes in
I have been reading more lately about the efficiency of the different selector engines.
I started with an InputStreamReader, but this buffered its input, reading more than was
I just began reading more about Markov Chain Generators today, and am really intrigued
Update: After some more reading I see that this problem is totally general, you
What reading would you recommend on general debugging techniques? I am more interested in
After reading http://www.pragprog.com/magazines/2010-03/javascript-its-not-just-for-browsers-any-more I'm wondering which is the best IDE to develop server-side javascript
Java is reading the locale, timezone and encoding information (and perhaps more) from the

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.