Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
70
xamDataTree wont display my business object
posted

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 Property
End Class

 

The code for binding is as follows:

Private WithEvents oDepartments As New DepartmentList
 '
' Departments
oDepartments = New DepartmentList
oDepartments.Add(New Department(1, 0, "Department A"))
oDepartments.Add(New Department(2, 0, "Department B"))
oDepartments.Add(New Department(3, 0, "Department C"))
'
' Sub-Departments
oDepartments(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-Departments
oDepartments(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.