views:

53

answers:

1

Hi folks,

I am currently using a Linq template with SubSonic3 to create my models. I have a simple Member class, which has a collection of Notes. A Note class has a PublishedDate and Title properties.

I have a UserControl which has a collection of Members for its DataContext. There are two ListBoxes and a bunch of TextBoxes and other controls on it. The first ListBox (membersList) gets its ItemsSource from the UserControl DataContext and it displays a few Member properties in each item. I would like the second ListBox (notesList) to display the Notes collection of the Member selected in the first ListBox.

So far on notesList I have:

<ListBox ... ItemsSource="{Binding Notes}"...>
    <DataTemplate>
        <TextBox Text="{Binding Title}"/>
    </DataTemplate>

It partially works. When I selected a Member which has Note items there is the correct number of items in notesListBox but this is only visible in the alternating row colours - nothing else! The DataTemplate fails to render the Title of the Note. Basically all the visual styles in the ListBox and ListBoxItem works - alternating colours, selection border, mouseover, etc. but the content is not shown. I have a feeling the problem is my Binding syntax but I can't figure out what's wrong.

Any suggestions would be greatly appreciated.

Cheers, Dany.

+1  A: 

Make sure your template includes a ContentPresenter. It sounds like you may have left this out when you templated your list box.

Leaving this out could lead to the behavior you're experiencing - full template, but no "content", since there's no place for it to place the actual items that should go in each list box item.

Reed Copsey
Hi Reed, thanks for the quick response. Yes, I already have a ContentPresenter in the control template. The ControlTemplates are identical for membersList and notesList - the only difference is the DataTemplates. The membersList ListBox is displaying quite nicely, the only problematic one is notesListBox.
DanyW