0

10個の要素ごとに抽出したいxmlドキュメントがあります。このコードを使用して最後の10個の要素を抽出し、10個の要素をスキップして古いものを取得しました。このコードを使用しましたが、最後の10個の要素をスキップすることで、古い最初のリストを最も古い10個を含む別のリストに置き換えます。最後の10個の要素を取得し、ユーザーがボタンを押すと、古いリストとその前にある別の10個の古い要素を取得します。

slideView.ItemsSource = 
    (from channel in xmlItems.Descendants("album")     
     orderby (int)channel.Element("catid") descending 
     select new onair
     {
         title = (string)channel.Element("name"),
         photo = (string)channel.Element("picture")
     }).Skip(10).Take(10);

何かアイデアをお願いします??

4

1 に答える 1

0

これまでのところ、Linq でページネーションを作成する必要があるだけです (このコードをケースに合わせてください)。

    public IEnumerable<onair> GetItems(int pageIndex = 0, int pageSize = 10)
    {
        return (from channel in xmlItems.Descendants("album")
                orderby (int)channel.Element("catid") descending
                select new onair
                {
                    title = (string)channel.Element("name"),
                    photo = (string)channel.Element("picture")
                }).Skip(pageIndex * pageSize).Take(pageSize);
    }
...

slideView.ItemsSource = GetItems(2,10):
于 2013-01-03T13:02:50.003 に答える