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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:08:40+00:00 2026-06-17T22:08:40+00:00

Possible Duplicate: How to use nested class in WPF XAML? I am refractoring the

  • 0

Possible Duplicate:
How to use nested class in WPF XAML?

I am refractoring the code from sample:

  • 24.129.21. Master Detail Binding
    from C# / CSharp Tutorial » Windows Presentation Foundation » Binding)

And after excluding Skills class, with corresponding changes in
in MainWindow.xaml

<local:Team>
  <local:Employee Name="Larry" Age="21">
    <local:Employee.Skills>
      <!--  local:Skills -->
       <local:Skills>

I am having in MainWindow1.xaml.cs:

using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
namespace WpfApplication
{
  public class Skill
  {//I'd like to remove class Skill having moved property string Description into class Employee 
    public string Description { get; set; }
  }

   public class Employee 
   {
    public string Name { get  ; set; }
    public int Age  { get; set; }
//I'd like to change in the next line Skill --> String               
    public List<Skill> Skills { get; set; }
    //public List<String> Skills { get; set; }

     public Employee()
     {
//I'd like to change in the next line Skill --> String       
       Skills=new List<Skill>();
       //Skills=new List<string>();
     }
  }

  public class Team : ObservableCollection<Employee> { }

  public class Company
  {
    public string CompanyName { get  ; set; }
    public Team Members { get  ; set; }
  }

  public class Companies : ObservableCollection<Company> { }

  public partial class Window1 : Window
    {
      public Window1()
    {
        InitializeComponent();
    }
  }
}

How should I change Window1.XAML if to change:

  • List<Skill> to List<String>

in Window1.xaml.cs?

Related questions based on the same code:

  • How to use nested class in WPF XAML?
  • Is it possible to use anonymous types in WPF XAML?

Update:
Just to note what I tried wrong:

  • “A” instead of A (without quotes);
  • it should be String (but not string) in XAML (while in C# either string or String)
  • tried to place A as attribute, according existed code, in one tag <sys:String />
    instead of: <sys:String>A</sys:String>
  • 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-17T22:08:41+00:00Added an answer on June 17, 2026 at 10:08 pm

    Here goes your Employee class with new approach you wanted it to be like –

    public class Employee
    {
        public string Name { get; set; }
        public int Age { get; set; }
        public List<String> Skills { get; set; }
    
        public Employee()
        {
            Skills=new List<string>();
        }
    }
    

    You can create the instance in xaml files for the same like this –

            <local:Team x:Key="teams">
                <local:Employee Name="Larry" Age="21">
                    <local:Employee.Skills>
                        <sys:String>A</sys:String>
                        <sys:String>B</sys:String>
                        <sys:String>C</sys:String>
                    </local:Employee.Skills>
                </local:Employee>
            </local:Team>
    

    You need to define sys namespace in your xaml to declare an instance of string in xaml –

    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    

    I tested the above code with ListBox and its working –

    <ListBox ItemsSource="{Binding Skills, Source={StaticResource teams}}"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Breaking out of nested loops in Java How can I use break
Possible Duplicate: Nested jQuery.each() - continue/break Here is my code: var steps = $(div#f);
Possible Duplicate: Use LINQ to read all nodes from XML I am trying to
Possible Duplicate: Use regular expressions to validate passwords I'm trying to code a php
Possible Duplicate: Breaking out of a nested loop I have this code foreach (___)
Possible Duplicate: Use of class definitions inside a method in Java Can we have
Possible Duplicate: How to use HTML Agility pack I have html code below: <div><span
Possible Duplicate: Why use getters and setters? Is there any advantage to making methods
Possible Duplicate: Proper Use of yield return What is the use of the yield
Possible Duplicate: Why use document.write? Considering the negative effects of document.write(), why are most

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.