You would create a View-Model Object that your XAML would bind to.
This View Model would contain private members of each class (model) that you want to display. It would wrap the properties of each private-class-member that needs to be displayed (that way the XAML can easily bind to the properties).
In this example your Model classes would be:
- Class
- Student
- Subject
- Address
Your View-Model class would have a private member of each of these classes:
-
Public Class StudentViewModel
-
Private _class As [Class]
-
Private _student As Student
-
Private _subject As Subject
-
Private _addresses As ObservableCollection(Of Address)
-
-
'The constructor for the Student View Model class
-
Public Sub New(ByVal class As [Class], ByVal student As Student, ByVal address As Address, ByVal subject As Subject)
-
_class = class
-
_student = student
-
_addresses = ObservableCollection(Of Address)
-
_subject = Subject
-
End Class
Now, you need to implement properties that expose the Model-class properties:
-
Public Class StudentViewModel
-
Private _class As [Class]
-
Private _student As Student
-
Private _subject As Subject
-
Private _addresses As ObservableCollection(Of Address)
-
-
Public Property StudentName As String
-
Get
-
Return _student.Name
-
End Get
-
Set(ByVal value As String)
-
_student.Name = value
-
End Set
-
End Property
-
Public ReadOnly Property Addresses As ObservableCollection(Of Address)
-
Get
-
Return _addresses
-
End Get
-
End Property
-
Public Property SubjectName As String
-
Get
-
Return _subject.Name
-
End Get
-
Set(ByVal value As String)
-
_subject.Name = value
-
End Set
-
End Property
-
-
'.......and so on'
-
-
'The constructor for the Student View Model class
-
Public Sub New(ByVal class As [Class], ByVal student As Student, ByVal addresses As List(Of Address), ByVal subject As Subject)
-
_class = class
-
_student = student
-
_subject = Subject
-
_addresses New ObservableCollection(Of Address)(addresses)
-
End Class
Now in your XAML you can bind objects to the Properties of your View Model to display/interact with the data.
-Frinny