I am doing hiearchical binding to the xamTree and successfully populate the tree to multiple levels.
My question is around binding to the checkboxes. I have read that I can bind to a property in my source tables however whether checked or not varies by user. So, for example, I have a number of hiearchical tables that populate the tree, but I need to bind the checked value based on a different table (queried by user to determine what is checked).
Can anyone give me some guidance on best practices to implement this? I could implement a model which rolls this data up into one hiearchical view, but if theire is an easier way to do it I would prefer...
Thanks!
Please, look at this forum thread for more details on binding the checkboxes in the XamTree.
Let me know if this is what you need.
Yes, thank you, I had seen that thread and it does help.
However, I was looking for more specific guidance on databinding the checkbox values to a different entity. One entity populates the tree and a different entity populates the checkboxes. In the thread example, the checkboxes are populated by a property of the SAME entity populating the tree.
I'm sure I can work it out with some specialized entity just for the above purpose, but I figure this is a very common scenario and I'd like to leverage anything already in the community. Just FYI, we are using WCF RIA services. Not specific to the problem but may help folks understand the architecture we're dealing with.
The problem with the scenario you are working with is that each tree node (similar to every item in a listbox) has a data context that is bound to a singluar object
So an item template laid out like this,will show that each node can only see one element of the items in the tree's ItemsSource property.
<ig:XamTree.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding}" />
</StackPanel>
</DataTemplate>
</ig:XamTree.ItemTemplate>
So you would have to find a way to bring your second object into the context to use it directly, which would mean compound object.
to get around this you might look into using a value converter on the IsChecked property of the checkbox. But you would still need to find a way to bring your second object into play. To do this in this sample I used a helper class. In this helper class I just do a little math to return a value, you would have to access your data level to get your value for the checked box and do the work.
Hi Darrell -
Thanks for the sample - I like the idea of using the converter.
However, I did run into a problem you might be able to help with?
In your example, you are creating a new checkbox in the DataTemplate for the TreeItem. I wanted to use the built-in checkbox functionality in the xamTree.
Recreating your example in the my project worked OK, here is xaml:
<ig:HierarchicalDataTemplate.ItemTemplate>
<CheckBox IsChecked="{Binding Converter={StaticResource myconv}, ConverterParameter={StaticResource data}}" />
<TextBlock Text="{Binding Name}" />
</ig:HierarchicalDataTemplate.ItemTemplate>
However, when I tried to bind to the TreeItem IsChecked property, the checkbox displays but I do not get the box checked as expected AND I no longer get the TextBlock binding working correctly. See example xaml below. Any help? I'm using 10.3 w/latest SR.
hi,
did you get a solution for this?
thanks
We ended up using the standard TreeView control. We were able to get it to do everything we wanted and had too many problems with the xamTree control.