Hi,
I have been successfully using the Syncfusion Treeview control with my business object but recently decided to move over to the xamDataTree. The problem is, when I bind my business object to this new control I only see the root 'department' values... no subdepartments are displayed.
My 'Department' class is recursive for sub-departments and sub-sub-departments etc. A sample of the class is as follows:
'========================' Collection of Departments'========================Public Class DepartmentList Inherits ObservableCollection(Of Department)
' ' other class level code... 'End Class
'========================' Department'========================Public Class Department Inherits NotifyPropertyChanged
' Properties Private _ID As Integer Private _parentID As Integer Private _name As String Private _subDepts As DepartmentList Private _isSelected As Boolean = False
#End Region
#Region "Properties"
Public Property ID() As Integer Get Return _ID End Get Set(ByVal value As Integer) _ID = value OnPropertyChanged(New PropertyChangedEventArgs("ID")) '_isChanged = True End Set End Property
Public Property ParentID() As Integer Get Return _parentID End Get Set(ByVal value As Integer) _parentID = value OnPropertyChanged(New PropertyChangedEventArgs("ParentID")) '_isChanged = True End Set End Property
Public Property Name() As String Get Return _name End Get Set(ByVal value As String) _name = value OnPropertyChanged(New PropertyChangedEventArgs("Name")) '_isChanged = True End Set End Property
Public Property SubDepartments() As DepartmentList Get Return _subDepts End Get Set(ByVal value As DepartmentList) _subDepts = value OnPropertyChanged(New PropertyChangedEventArgs("SubDepartments")) End Set End Property
Public Overrides Function ToString() As String Return _name End Function#End Region
End Class
'========================' Notification Class'========================''' </summary>Public Class NotifyPropertyChanged Implements INotifyPropertyChanged
Private _isChanged As Boolean
#Region "Implementations" Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Public Sub OnPropertyChanged(ByVal e As PropertyChangedEventArgs, Optional ByVal IgnoreChangedFlag As Boolean = False) If Not PropertyChangedEvent Is Nothing Then RaiseEvent PropertyChanged(Me, e) If Not IgnoreChangedFlag Then _isChanged = True End If End Sub#End Region
Public Property IsChanged() As Boolean Get Return _isChanged End Get Set(ByVal value As Boolean) _isChanged = value End Set End PropertyEnd Class
The code for binding is as follows:
Private WithEvents oDepartments As New DepartmentList '' DepartmentsoDepartments = New DepartmentListoDepartments.Add(New Department(1, 0, "Department A"))oDepartments.Add(New Department(2, 0, "Department B"))oDepartments.Add(New Department(3, 0, "Department C"))'' Sub-DepartmentsoDepartments(0).SubDepartments.Add(New Department(4, 1, "Sub-department 1"))oDepartments(0).SubDepartments.Add(New Department(5, 1, "Sub-department 2"))oDepartments(0).SubDepartments.Add(New Department(6, 1, "Sub-department 3"))'' Sub-Sub-DepartmentsoDepartments(0).SubDepartments.Item(2).SubDepartments.Add(New Department(7, 6, "SUB-Sub-dept 3A."))oDepartments(0).SubDepartments.Item(2).SubDepartments.Add(New Department(8, 6, "SUB-Sub-dept 3B.")) 'treView.ItemsSource = oDepartments
I have tried various 'GlobalNodeLayouts' settings for the xamDataTree but to no avail; I still only see the base department level. Please help.
Hello,
Thank you for your post. I have been looking through it and I created a sample project for you using your code, where everything works as expected. Basically you should define each NodeLayout, when you use the XamDataTree. I used C# just to represent the same data as yours, but the thing you need is in the XAML code, so I believe you want have any difficulties, in case you have, feel free to write me. Here you can read more about defining NodeLayouts in XDT:
http://help.infragistics.com/NetAdvantage/WPF/2011.1/CLR4.0/?page=xamDataTree_Node_Layouts.html
Hope this helps you.
In your code you set xamDataTree1.ItemsSource, but in my code it's protected, so I cannot set it! How is this possible? Did you guys release a patch since this post changing ItemsSource to protected internal, as it is now?
I really need to set ItemsSource manually as the source I must use is constructed at run time and depends on data analysis.
I am having a similar prolem with the 12.1 XamDataTree. I'm not sure what I'm doing wrong but here's the code and the XAML. The xamDataTree is only showing my top level attributes (1-5), and not showing expand icon or second level attribute 1.1. (ps how should I upload code without getting the huge spaces??):
public class FormulaAttributeViewModel : ViewModelBase { private AttributeList _childAttributes; public string AttributeID { get; set; } public AttributeList ChildAttributes { get { return _childAttributes; } set { _childAttributes = value; } } }
this.FormulaAttributeViewModels = new AttributeList();
this.FormulaAttributeViewModels.Add(new FormulaAttributeViewModel() { AttributeID = "Attribute 1", ChildAttributes = new AttributeList() }); this.FormulaAttributeViewModels.Add(new FormulaAttributeViewModel() { AttributeID = "Attribute 2", ChildAttributes = new AttributeList() }); this.FormulaAttributeViewModels.Add(new FormulaAttributeViewModel() { AttributeID = "Attribute 3", ChildAttributes = new AttributeList() }); this.FormulaAttributeViewModels.Add(new FormulaAttributeViewModel() { AttributeID = "Attribute 4", ChildAttributes = new AttributeList() }); this.FormulaAttributeViewModels.Add(new FormulaAttributeViewModel() { AttributeID = "Attribute 5", ChildAttributes = new AttributeList() }); this.FormulaAttributeViewModels[0].ChildAttributes.Add(new FormulaAttributeViewModel() { AttributeID = "Attribute 1.1" });
XAML:
<ig:XamDataTree x:Name="xamDataTreeAttributes" Grid.Row="0" Grid.Column="0" MinWidth="200" ItemsSource="{Binding Path=FormulaAttributeViewModels}" VerticalAlignment="Top"><ig:XamDataTree.CheckBoxSettings><ig:CheckBoxSettings CheckBoxVisibility="Visible"/></ig:XamDataTree.CheckBoxSettings><ig:XamDataTree.GlobalNodeLayouts><ig:NodeLayout Key="AttributesLevel1" TargetTypeName="FormulaAttributeViewModel" DisplayMemberPath="AttributeID"/><ig:NodeLayout Key="AttributesLevel2" TargetTypeName="FormulaAttributeViewModel" DisplayMemberPath="AttributeID"/><ig:NodeLayout Key="AttributesLevel3" TargetTypeName="FormulaAttributeViewModel" DisplayMemberPath="AttributeID"/></ig:XamDataTree.GlobalNodeLayouts></ig:XamDataTree>
I appreciate your help. Thanks.