Hi All, I have a requirement wherein I need to have one listbox into another. I have a table that has a lot of records, some fields being redundant. I want to have unique headers of those fields displayed, but display all other fields in that record in another list box. I want the HotelName to be displayed and then I want the Hotel blocks to be displayed for each name. To get unique records I am using a HashSet. I am able to display the roomBlock data correctly but somehow, when I bind another listbox to HashSet collection Hotelnm, it doesnt display any text.
+3
A:
You aren't getting any items in the ListBox because you haven't bound a collection to it. Setting Hotelnm as the DataContext allows Bindings to be created against it but to get items in the ListBox you need to bind the ItemsSource property. You can either change the code to set ItemsSource instead of DataContext or add ItemsSource="{Binding}"
in XAML.
Inside your ItemTemplate the DataContext will be a single item of the collection, in this case a string. To display the item as a TextBlock's Text again use Text="{Binding}"
to use the DataContext object itself.
John Bowen
2010-08-26 22:36:54