views:

36

answers:

0

I would like to know if there is a way to connect to multiple resources:

Specifically I have the following problem

abstact class BaseClass
{
  ObservableCollection<BaseClass>;
}

class GrandSonClass:BaseClass{}

class SonClass:BaseClass{}

class FatherClass:BaseClass
{
  CollectionViewSource col = new CollectionViewSource ;
  col.Source = Items.SelectMany(p => p.Items);
}

FatherClass's Items are of ChildrenClass type, and ChildrenClass's Items are of GrandSonClass type;

I want FatherClass to bind to all the GrandSonClass's items it possesses.

The solution of using SelectMany is not good as I need this to be dynamically updated whenever FatherClass adds more Items and whenever its Items(SonClasses) add more Items.

Now I could go on and write notifiaction events but I was wondering if there is a smarter way to do it

-i.e. simply define the sources as the Items of each Item FatherClass posses

I have this Data Structure

Father

|

|___Child1

|------|___GrandChild1

|------|___GrandChild2

|___Child2

|-------|___GrandChild3

|-------|___GrandChild4

I want to see a tree like this TreeView

Father

|

|___GrandChild1

|___GrandChild2

|___GrandChild3

|___GrandChild4

The Items are connected via ItemsSource. I want the TreeView to be updated with the data whenever a child or grandchildren are added or deleted

The children are an ObseravbleCollection of the father and the garndchildren are Observable Collection of the children (it is a reursive Hierachial data structure all using the same type of class