Use object properties in LongListSelector (XAML)

和自甴很熟 提交于 2019-12-13 04:50:05

问题


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.


回答1:


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/>


来源:https://stackoverflow.com/questions/20719537/use-object-properties-in-longlistselector-xaml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!