I am trying to bind a breadcrumb control to a hierarchical data source, so far without success.
My data source is a clr object, already instantiated when the breadcrumb control is instantiated.
First question - can this be done? (the quick start on this topic binds only to an xml data source).
The object I want to bind to is a very uniform tree - I keep thinking this should be easy. It is a tree where every node is of this type (somewhat simplified):
public class Item
{
private string name;
... other properties ...
private List<Item> childItems;
public string Name
{
get { return this.name; }
set { this.name = value; }
}
... accessors for other properties ...
public List<Item> ChildItems
{
get { return this.childItems; }
set { this.childItems= value; }
}
public Item()
{
this.childItems= new List<Item>();
}
}
I want the TextBlock of the BreadcrumbItem to show the Name property and the TextBlock of the MenuItems to show the ChildItems' Name property. The tree is not of fixed depth. There can be zero or more ChildItems attached to any Item. I want to give a single object of type Item to the breadcrumb control to be its root. It should navigate the tree itself knowing that the ItemSource for the next level down is always ChildItems. I need to be able to bind the root to the breadcrumb in c# code so it is dynamic.
Second question: Help? I have tried using both approaches (Styles only and Hierarchical Data Templates + Styles) without success.
Thanks,
John
My data source is a clr object, already instantiated when the breadcrumb control is instantiated.
First question - can this be done? (the quick start on this topic binds only to an xml data source).
The object I want to bind to is a very uniform tree - I keep thinking this should be easy. It is a tree where every node is of this type (somewhat simplified):
public class Item
{
private string name;
... other properties ...
private List<Item> childItems;
public string Name
{
get { return this.name; }
set { this.name = value; }
}
... accessors for other properties ...
public List<Item> ChildItems
{
get { return this.childItems; }
set { this.childItems= value; }
}
public Item()
{
this.childItems= new List<Item>();
}
}
I want the TextBlock of the BreadcrumbItem to show the Name property and the TextBlock of the MenuItems to show the ChildItems' Name property. The tree is not of fixed depth. There can be zero or more ChildItems attached to any Item. I want to give a single object of type Item to the breadcrumb control to be its root. It should navigate the tree itself knowing that the ItemSource for the next level down is always ChildItems. I need to be able to bind the root to the breadcrumb in c# code so it is dynamic.
Second question: Help? I have tried using both approaches (Styles only and Hierarchical Data Templates + Styles) without success.
Thanks,
John