在 LongListSelector (XAML) 中使用对象属性 [英] Use object properties in LongListSelector (XAML)

查看:34
本文介绍了在 LongListSelector (XAML) 中使用对象属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 LongListSelector 在我的 WP8 应用程序中显示笔记列表.我使用了一个 Note 列表(Note 是我的对象名称)并且 Note 有两个属性:TitreContenu.简单地说,我想在我的 LongListSelector 中显示我的对象的 Titre 属性.我有这个代码:ListeNotes.ItemsSource = ListNotes(因为 ListNotes 是我的 List 的名称,而 ListeNotes 是我的 LongListSelector 的名称).但它显示了一个只包含 CloudyNote 的列表.注意我有笔记的次数.如何在 LongListSelector 中显示 Title 属性而不是对象名称?提前致谢.

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.

推荐答案

尝试定义 ItemTemplate 指定要显示的属性:

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

这篇关于在 LongListSelector (XAML) 中使用对象属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆