1

I am trying to create a grid containing elements such as

| 1 | 4 | 7 | 
| 2 | 5 | 8 | ===> extend
| 3 | 6 | 9 |

Since the data is very large, I need to use UI virtualization and what I see in most example is the VirtualizingStackPanel

Here is how I have setup my Gridview in XAML . The problem is that the following code creates a horizontal row of single element (which makes sense given it is just a stack panel).

| 1 | 2 | 3 | 4 | .....


        <GridView
        x:Name="itemGridView"
        AutomationProperties.AutomationId="ItemsGridView"
        AutomationProperties.Name="Items"
        TabIndex="1"
        Grid.RowSpan="3"
        Padding="116,136,116,46"
        ItemsSource="{Binding Source={StaticResource itemsViewSource}}"
        ItemTemplateSelector="{StaticResource CellStyleSelector}"
        ItemClick="ItemView_ItemClick"            
        IsItemClickEnabled="True"
        SelectionMode="Extended"
        SelectionChanged="ItemView_SelectionChanged"
        IsSwipeEnabled="true">
        <GridView.ItemsPanel>
            <ItemsPanelTemplate>
                <VirtualizingStackPanel Orientation="Horizontal"/>
            </ItemsPanelTemplate>
        </GridView.ItemsPanel>
    </GridView>

How would one go about making it display a grid that extends horizontally using virtualizingstackpanel? I have no groups in my data so all the examples that show virtualizingstackpanel show this ? I am completely new at Windows Store app dev (mostly have been on iOS and Android ) so would appreciate any code sample or resources.

Thank you

4

1 回答 1

1

我认为您正在通过将数据源实现到 interface 来进行 UI 虚拟化ISupportIncrementalLoading。尝试WrapGrid,并设置MaximumRowsOrColumns

<GridView
    x:Name="itemGridView"
    AutomationProperties.AutomationId="ItemsGridView"
    AutomationProperties.Name="Items"
    TabIndex="1"
    Grid.RowSpan="3"
    Padding="116,136,116,46"
    ItemsSource="{Binding Source={StaticResource itemsViewSource}}"
    ItemTemplateSelector="{StaticResource CellStyleSelector}"
    ItemClick="ItemView_ItemClick"            
    IsItemClickEnabled="True"
    SelectionMode="Extended"
    SelectionChanged="ItemView_SelectionChanged"
    IsSwipeEnabled="true">
    <GridView.ItemsPanel>
        <ItemsPanelTemplate>
            <WrapGrid MaximumRowsOrColumns="3" Orientation="Horizontal"/>
        </ItemsPanelTemplate>
    </GridView.ItemsPanel>
</GridView>
于 2013-07-24T05:22:10.533 回答