WinRT ItemTemplateSelector

Topics: Conventions
Apr 17, 2013 at 5:54 PM
Edited Apr 17, 2013 at 5:54 PM
I'm trying to use an ItemTemplateSelector on a ListView, however it's not working. I believe Caliburn is not finding an ItemTemplate and is assigning one by default.

Is this right?


(P.S. It works if I use explicit Binding)
Apr 21, 2013 at 3:23 AM
Just to clarify you're using an x:Name on the ListView with an ItemTemplateSelector specified as well?
Apr 22, 2013 at 8:34 PM
Sorry. This is now working, but I've updated Caliburn since wednesday and this now is working. Don't know if that was the solution.
Apr 22, 2013 at 9:21 PM
I don't get it. I just got the same problem:

I have the following code:

        <selectors:NoteItemTemplateSelector x:Key="NoteItemTemplateSelector" 
                                            ReadTemplate="{StaticResource Notes600ConversationTemplate}"
                                            UnreadTemplate="{StaticResource Notes600ConversationTemplateUnread}"/>
<ListView x:Name="Conversations"
               ItemTemplateSelector="{StaticResource NoteItemTemplateSelector}">
           <Style TargetType="ListViewItem">
               <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
With this code, each item has a message: Cannot find view for ...blah blah.Converstation

If I add this code to the listView, it works ok:
ItemsSource="{Binding Conversations}"

Am I missing something?
Apr 22, 2013 at 10:01 PM
It looks like there's a logic flaw in the conventions, the ConventionManager currently isn't expecting the ItemTemplateSelector property to see whether it should use the default ItemTemplate. The ListView then uses the ItemTemplate that Caliburn Micro sets rather than the ItemTemplateSelector

By adding the ItemsSource binding yourself you short circuit the conventions.
Apr 22, 2013 at 10:13 PM