Binding to an ObservableCollection of UserControls

Posted by nlawalker on Stack Overflow See other posts from Stack Overflow or by nlawalker
Published on 2010-05-22T19:37:40Z Indexed on 2010/05/22 19:40 UTC
Read the original article Hit count: 244

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about databinding