나는 관찰 가능한 컬렉션을 바인딩하고 사용하는 방법을 여전히 가르쳐왔다. 약간 혼란스러운 문제는 여러 클래스/관찰 가능한 컬렉션을 한 페이지에 바인딩하는 것입니다. 즉, PersonName 클래스와 AnimalName 클래스가있는 경우 각각에 대해 두 개의 별도 observalbe 컬렉션을 만들어야합니다. 페이지에서 하나만 허용하는 경우 어떻게 datacontext를 설정합니까? 예를 들어Observable 컬렉션에 여러 클래스를 추가하는 방법
: 나는 다른 클래스를 추가하는 경우
Public Class NameList
Inherits ObservableCollection(Of PersonName)
' Methods
Public Sub New()
MyBase.Add(New PersonName("Willa", "Cather"))
MyBase.Add(New PersonName("Isak", "Dinesen"))
MyBase.Add(New PersonName("Victor", "Hugo"))
MyBase.Add(New PersonName("Jules", "Verne"))
End Sub
End Class
Public Class PersonName
' Methods
Public Sub New(ByVal first As String, ByVal last As String)
Me._firstName = first
Me._lastName = last
End Sub
' Properties
Public Property FirstName() As String
Get
Return Me._firstName
End Get
Set(ByVal value As String)
Me._firstName = value
End Set
End Property
Public Property LastName() As String
Get
Return Me._lastName
End Get
Set(ByVal value As String)
Me._lastName = value
End Set
End Property
' Fields
Private _firstName As String
Private _lastName As String
End Class
지금, 내가 어떻게 바인딩 부분 및 수집 부분에 두 가지를 결합 할 것이다. 어떤 조언을 주셔서 감사합니다 :)
public class AnimalName
'properties, ect...ect..ect..
End class