I have a list of type objects Foo. Each object Foocontains a link to the parent:
public class Foo
{
public Foo Parent { get; set; }
}
(If Parentnull, it Foois considered the "root" of the node.) As you can see, this implies a kind of bottom-up tree hierarchy.
I would like to flip this child> parent relationship in reverse order by wrapping my objects Fooin a new class TreeItem;
public class TreeItem<T>
{
public T Item { get; set; }
public IEnumerable<TreeItem<T>> Children { get; set; }
}
As shown, this will give me a more natural top-down tree hierarchy. I believe that this will greatly simplify data binding, for example. in WPF TreeView.
Linq, List<Foo>, Foo TreeItem<Foo>?
Linq, ?
. , " "?