I was reading this post StackOverFlowPost but I think I need more than that. Here is my situation. I am trying to fill a TreeView with items from a class with two different types ObservableCollection's. Here is the class definition:
public class User : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(PropertyChangedEventArgs e)
{
if (PropertyChanged != null)
PropertyChanged(this, e);
}
private string _Username;
public string Username
{
get { return this._Username; }
set
{
this._Username = value;
OnPropertyChanged(new PropertyChangedEventArgs("Username"));
}
}
private ObservableCollection<Computer> _UserComputers;
public ObservableCollection<Computer> UserComputers
{
get { return this._UserComputers; }
set
{
this._UserComputers = value;
OnPropertyChanged(new PropertyChangedEventArgs("UserComputers"));
}
}
private ObservableCollection<CellPhone> _UserCellPhones;
public ObservableCollection<CellPhone> UserCellPhones
{
get { return this._UserCellPhones; }
set
{
this._UserCellPhones = value;
OnPropertyChanged(new PropertyChangedEventArgs("UserCellPhones"));
}
}
public User()
{
this.UserComputers = new ObservableCollection<Computer>();
this.UserCellPhones = new ObservableCollection<CellPhone>();
}
}
I would like the TreeView to look like the following:
- Brian
- (child)Computer
- (child)CellPhone
Every example I can find only shows how to fill a TreeView with the Class->Class->Class->Properties Association format. I would like to do a Class->2Classes->Properties format.
Any help would be greatly appreciated. Thanks,
-Brian