3

標準のItemGridViewテンプレートを使用して、ニーズに合わせて少し変更しました。実際、テンプレートコードはほとんど変更していません。

私は1つのグループを持っていて、その中にたくさんのアイテム(92アイテム)があります。リストビューはそれらのいくつかをレンダリングしますが、12個しかレンダリングしません。何故ですか?それをオーバーライドして、すべてのアイテムを表示させるにはどうすればよいですか?

DefaultViewModelを設定しているときに、デバッガーに侵入したスクリーンショットを次に示します。 ここに画像の説明を入力してください

次のようにリストビューにアイテムを追加します(サービスからXMLを解析するとき)。

DataSource.AddItem(new DataItem(... title, name, etc, DataSource.getGroup("gallery")));

次に、DataSourceクラス(これはサンプルとまったく同じで、名前を変更しただけです)に、次のメソッドを追加しました。

public static void AddItem(DataItem item)
{
    item.Group.Items.Add(item);
}

これをレンダリングするXAMLは次のようになります(GridViewテンプレートと同じです:

    <GridView.ItemsPanel>
                <ItemsPanelTemplate>                        
                    <VirtualizingStackPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </GridView.ItemsPanel>
            <GridView.GroupStyle>
                <GroupStyle>
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <Grid Margin="1,0,0,6">
                                <Button
                                    AutomationProperties.Name="Group Title"
                                    Content="{Binding Title}"
                                    Click="Header_Click"
                                    Style="{StaticResource TextButtonStyle}"/>
                            </Grid>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                    <GroupStyle.Panel>
                        <ItemsPanelTemplate>
                            <VariableSizedWrapGrid Orientation="Vertical" Margin="0,0,80,0"/>
                        </ItemsPanelTemplate>
                    </GroupStyle.Panel>
                </GroupStyle>
            </GridView.GroupStyle>
        </GridView>

助けていただければ幸いです。

4

1 に答える 1

7

グリッドアプリケーションテンプレートは、以下のコメントで説明されている理由により、各グループに表示されるアイテムの数を12に制限しています。

public class SampleDataGroup : SampleDataCommon
{
    ...
    public IEnumerable<SampleDataItem> TopItems
    {
        // Provides a subset of the full items collection to bind to from a GroupedItemsPage
        // for two reasons: GridView will not virtualize large items collections, and it
        // improves the user experience when browsing through groups with large numbers of
        // items.
        //
        // A maximum of 12 items are displayed because it results in filled grid columns
        // whether there are 1, 2, 3, 4, or 6 rows displayed
        get { return this._items.Take(12); }
    }
}
于 2012-06-25T07:56:40.560 に答える