Reputation: 6514
Simple Silverlight question: I have an ObservableCollection<MyObject> in my viewmodel. Every MyObject has a Label property. If I bind a ListBox to the collection and set DisplayMemberPath to Label, or set the ItemTemplate to a TextBlock that binds the Text property to Label, all works as expected.
If I change MyObject so it derives from a UserControl, the Label text no longer shows up in the ListBox; each item just shows up as a blank strip a few pixels tall. Why is this? There's obviously something I'm missing here about how different things get rendered.
Upvotes: 1
Views: 251
Reputation: 189437
The ListBox determines that the set of items in its ItemsSource
are already UIElement
instances and therefore decides to use those elements directly as the content of the ListBoxItem
elements it creates.
Upvotes: 2