0
出於某種原因,我將findall函數中的每個項目添加到observable集合中,並且我在列表框中取回「groupname」..而不是組的實際名稱。ObservableCollection返回錯誤類型
Dim ctx As New PrincipalContext(ContextType.Domain)
Dim qbeGroup As New GroupPrincipal(ctx)
Dim srch As New PrincipalSearcher(qbeGroup)
For Each item In srch.FindAll()
GroupsList.Add(New groups With { _
.name = item.Name
})
Next
下面是我簡單的ObservableCollection
Public Property name() As String
Get
Return m_name
End Get
Set(value As String)
m_name = value
End Set
End Property
Private m_name As String
有沒有別的東西,我需要做返回的實際字符串?
編輯:XAML中
<ListBox x:Name="lbAvGroups_Copy" HorizontalAlignment="Left" Height="470" VerticalAlignment="Top" Width="355" Margin="392,35,0,0"/>
我在後臺代碼的結合,所以這是我的約束力的樣子。
Public View As ICollectionView
Public GroupsList As new ObservableCollection(Of groups)
View = CollectionViewSource.GetDefaultView(GroupsList)
lbAvGroups.ItemsSource = View
您的列表框的XAML代碼是什麼樣的? – Mark
編輯顯示xaml和相關的綁定代碼。如果我在for循環中添加messagebox.show(item.name),它將顯示實際的名稱。 – TonyW
嘗試添加'lbAvGroups.DisplayMemberPath =「name」' - 我相信它會使用'ToString'返回的任何內容。 – Mark