Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Observable collection add children

$
0
0

I have an ObservableCollection,

    public class Company : ObservableCollection<Employee>
            {
                public Company(string P_companyName){

                    companyName = P_companyName;
                }

                public string companyName{ get; set; }
            }

It is an ObservableCollection of this;

public class Employee
        {
            public string FirstName{get;set;}
            public string LastName{get;set;}
            public string City{get;set;}
        }

I've made a List like this;

List<Company> companiesWemployees = new List<Company>();

This is the way to add an item,

companiesWemployees.Add(new Company("Xamarin"){

    new Employee { FirstName = "John", LastName = "Doe", City = "LA"},
    new Employee { FirstName = "Jane", LastName = "Doe", City = "NY"}
});

Is it possible to add a single employee to the list without adding a company name?


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>