简体   繁体   中英

Binding data to a long list selector, C# WP8

I've got a database and am looking to list all the items found into a longlist selector, it currently works, however the it doesn't display the actual text, just the object reference:

   //this will return all the records found in file table
        var query = context.Files;

        //now execute the query
        fileList = new ObservableCollection<FileTable>(query);

        //set up list items.
        llsEachItem.ItemsSource = fileList;

The longlist selector then just displays The object reference, for each item not the actual data itself. In this case it displays a list of:

Project.Model.FileTable
Project.Model.FileTable
Project.Model.FileTable
Project.Model.FileTable
Project.Model.FileTable

How can I make it so that I can actually see the data itself? I've tried appending toString() to the fileList but that doesn't seem to work. Any suggestions?

Set DisplayMemberPath on list to the property name which you want to be shown in your list.

llsEachItem.ItemsSource = fileList;
llsEachItem.DisplayMemberPath = "PropertyName";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM