簡體   English   中英

將數據綁定到長列表選擇器C#WP8

[英]Binding data to a long list selector, C# WP8

我有一個數據庫,我希望列出找到長列表選擇器的所有項目,它目前有效,但它不顯示實際文本,只是對象引用:

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

然后,長列表選擇器只顯示對象引用,對於每個項目而不是實際數據本身。 在這種情況下,它會顯示以下列表:

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

我怎樣才能讓它實際看到數據本身? 我已經嘗試將toString()附加到fileList,但這似乎不起作用。 有什么建議么?

將列表中的DisplayMemberPath設置為要在列表中顯示的屬性名稱。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM