How do we bind the xamWebTree checkbox to a bool field in the data source?
For example, assuming the xamWebTree is bounded to
to a Categories collection with nested Products data. How can we get the checkbox values for the corresponding categories and products? Is there a way to bind the checkbox to a bool property in Category and Product?
What we are trying to do is ?
When the checkbox is selected on UI, we want to perform certain action on server and client. So how can we read the checkbox?
Thanks,
Hi,
So, the best way to bind a CheckBox to a bool field in your data source, is to use the ItemTemplate or HierarchicalItemTemplate property of the xamWebTree and place a Checkbox inside of it.
<igTree:XamWebTree.HierarchicalItemTemplate> <ig:HierarchicalDataTemplate ItemsSource="{Binding Path=Products}"> <ig:HierarchicalDataTemplate.ItemTemplate> <DataTemplate> <CheckBox Content="{Binding ProductName}" IsChecked="{Binding MyProductBoolProperty, Mode=TwoWay}"> </DataTemplate> </ig:HierarchicalDataTemplate.ItemTemplate> <DataTemplate> <CheckBox Content="{Binding CategoryName}" IsChecked="{Binding MyCategoryBoolProperty, Mode=TwoWay}"> </DataTemplate> </ig:HierarchicalDataTemplate> </igTree:XamWebTree.HierarchicalItemTemplate>
Hope this helps,
-SteveZ
Hi Stephen,
Thanks very much for the reply. It provides a way to bind a CheckBox to a bool property in my data source. However, I would like to use the CheckBox that comes with the xamWebTree (where the CheckBoxVisibility attribute is set to Visible), instead of manually place a CheckBox on each tree node. Any help is greatly appreciated.