Hello,
I am trying to use the XamTree to show hierarchial data, that recurses through it's child items to an unknown level of nodes.
I have tried the sample that is posted here:
https://ko.infragistics.com/community/blogs/b/curtis_taylor/posts/control-monster-explores-multi-level-xamtrees-part-ii#commentmessage
However, this seems to have to create a HierarchialItemTemplate and associated HierarchialDataTemplate for each level in the tree.
Is it possible to do this with the XamTree? I have been able to successfully achieve this using the built in Silverlight TreeView, but I would like to transition to the XamTree.
Thanks
Gary
Hello Brian,
Thanks for getting back to me. This was exactly the issue. Changing to an ObservableCollection did the trick.
If you are using a collection type of List, then your view is not getting the change notification when new items are added to the collection. Try using an ObservableCollection.
I have an object that looks like this:
public class Person : INotifyPropertyChanged
{
private string _name;
public string Name
get { return _name; }
set
_name =
value;
NotifyPropertyChanged(
"Name");
}
private ObservableCollection<Person> _child = new ObservableCollection<Person>();
public ObservableCollection<Person> Child
get { return _child; }
_child =
"Child");
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void NotifyPropertyChanged(string propertyname)
var handler = PropertyChanged;
if (handler != null)
handler(
this, new PropertyChangedEventArgs(propertyname));
A ViewModel that looks like this:
public class MyViewModel : INotifyPropertyChanged
private ObservableCollection<Person> _people;
public ObservableCollection<Person> People
get { return _people; }
_people =
"People");
public MyViewModel()
People =
new ObservableCollection<Person>();
Person p1 = new Person() { Name = "1" };
Person a = new Person() { Name = "a" };
p1.Child.Add(a);
Person b = new Person() { Name = "b" };
p1.Child.Add(b);
Person p2 = new Person() { Name = "2" };
Person a2 = new Person() { Name = "a" };
p2.Child.Add(a2);
Person b2 = new Person() { Name = "b" };
p2.Child.Add(b2);
People.Add(p1);
People.Add(p2);
And my XAML looks like this:
<ig:XamDataTree ItemsSource="{Binding People}" >
<ig:XamDataTree.GlobalNodeLayouts>
<ig:NodeLayout Key="Standard" TargetTypeName="Person" DisplayMemberPath="Name"/>
</ig:XamDataTree.GlobalNodeLayouts>
</ig:XamDataTree>
Thank you for getting back to me about this, and I understand the need for the Product Idea Request.
However, in another thread, it was suggested that I should be able to use the XamDataTree to provide the additional n-level depth requirement.
What I have is something like the following:
Tree
-- List
Where each TreeNode itself has a List
i.e. a Fully Recursive Tree, which I am trying to display in the XamDataTree. I have defined a GlobalNodeLayout as follows:
But I only ever get the first items in the collection, it doesn't show the child items.
<ig:XamDataTree x:Name="MyTree"> <ig:XamDataTree.GlobalNodeLayouts> <ig:NodeLayout Key="TreeNodeLayout" TargetTypeName="TreeNode" DisplayMemberPath="Caption"> </ig:NodeLayout> </ig:XamDataTree.GlobalNodeLayouts> </ig:XamDataTree>
Am I missing something? All the examples that I have seen always have say a Product, with a child node type of Category. In my case, the child nodes are the same type. Any ideas?
Looking at the sample of the XamDataTree, this looks like it will do exactly what is required. I will give it a try, and let you know how I get on.
I would recommend using the xamDataTree instead since you are data binding to a collection of objects. You can define a layout for all the objects or for different types of objects.