I have a ListBox in WPF that I am trying to bind a class to that is a list with 2 properties which are FirstName and LastName. I bind the ItemSource and DisplayMemberPath in XAML and all works fine.
I now need to do this in code but all I see is the list with the class name so the DisplayMemberPath is not being bound correctly.
Dim b1 As New Binding
b1.Source = dc.People
Dim b2 As New Binding
b2.Path = New PropertyPath("FirstName")
BindingOperations.SetBinding(myListBox, ListBox.ItemsSourceProperty, b1)
BindingOperations.SetBinding(myListBox, ListBox.DisplayMemberPathProperty, b2)