Hello, I have a XamDataTree defined as follows:
<ig:XamDataTree x:Name="_MenuTree" ItemsSource="{Binding Menus}" SelectedDataItems="{Binding SelectedMenuItems}" NodeLineVisibility="Visible" IsExpandedMemberPath="IsExpanded" NodeCheckedChanged="TreeNodeCheckedChanged"> <ig:XamDataTree.CheckBoxSettings> <ig:CheckBoxSettings CheckBoxVisibility="Visible" CheckBoxMode="Auto" /> </ig:XamDataTree.CheckBoxSettings> <ig:XamDataTree.SelectionSettings> <ig:TreeSelectionSettings NodeSelection="Multiple" /> </ig:XamDataTree.SelectionSettings> <ig:XamDataTree.GlobalNodeLayouts> <ig:NodeLayout Key="MenuLayout" TargetTypeName="clsMenuItem" DisplayMemberPath="Description" CheckBoxMemberPath="IsSelected"> </ig:NodeLayout> </ig:XamDataTree.GlobalNodeLayouts> </ig:XamDataTree>
The Menus property is in the ViewModel and is an ObservableCollection of clsMenuItem. clsMenuItem has the following properties: ID (int), Description (string) and ChildItems (ObservableCollection(of clsMenuItem))
I looked at one of the other similar posts on the forums board, but in my case, I don't see anything on the screen when then form loads, even though the Menus property has proper stuff in it.
What am I missing / doing wrong?
Hello Manasi,
Your code appears to be correct, unless there is some sort of issue with data context not being propagated down to the tree, I don’t see any issue with this. I created a sample using the description of your data and your XAML and the tree appeared as expected. Please review the sample and see if you notice may differences which may attribute to your issue.
Let me know if you have any questions.
Sincerely
Valerie
Software Developer
Infragistics Inc
hi Valerie, apparently the ItemSource was being filled after the controls were loaded. I just assigned the "Menus" property in Form Loaded event and it worked fine. Now I have another question:
1) When the form loads, if there are only some child nodes checked and others unchecked, the parent node does not show the "-" (partially selected). But if I check / uncheck on the form, then the sign shows up. Is there something I have to do in the code-behind to show the right states of all check-boxes when the form loads?
2) Can I show Green Check and Red Cross images when the user checks / unchecks something on the form? How can I assign image property to a node depending on whether it is checked or unchecked?
Thanks,
Manasi
PS: I tried to add an image here, didn't show up??