Search code examples
.netvb.netxamlwindows-phone-8longlistselector

Use object properties in LongListSelector (XAML)


I'm trying to use the LongListSelector to show a list of notes in my WP8 application. I use a list of Note (Note is my object name) and Note has two properties : Titre and Contenu. Simply, I want to display the Titre property of my object in my LongListSelector. I have this code : ListeNotes.ItemsSource = ListNotes (because ListNotes is my List's name and ListeNotes is my LongListSelector's name). But it shows a list containing only CloudyNote.Note the number of time I have notes. How could I do to show the Title property instead of the object name in my LongListSelector ? Thank you in advance.


Solution

  • Try to define ItemTemplate specifying which property to display :

    <phone:LongListSelector>
        <phone:LongListSelector.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding Titre}"/>
            </DataTemplate>
        </phone:LongListSelector.ItemTemplate>
    
        ...
    
    <phone:LongListSelector/>