处理GridView中的行数

时间:2014-03-24 13:36:32

标签: c# xaml gridview windows-8 windows-8.1

我需要创建一个GridView,它只有1行和多列。

因为我想实现SemanticZoom并滚动到视图中。

GridView由CustomUserControls填充,这里是我的代码:

<SemanticZoom IsZoomOutButtonEnabled="False">
        <SemanticZoom.ZoomedInView>
            <GridView x:Name="ZoomedInView" VerticalAlignment="Center" SelectionMode="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ItemContainerStyle="{StaticResource GridViewItemStyle}">
                <GridView.GroupStyle>
                    <GroupStyle>
                        <GroupStyle.Panel>
                            <ItemsPanelTemplate>
                                <VariableSizedWrapGrid MaximumRowsOrColumns="1" Orientation="Horizontal" />
                            </ItemsPanelTemplate>
                        </GroupStyle.Panel>
                    </GroupStyle>
                </GridView.GroupStyle>
                <Controls:FirstControl VerticalAlignment="Stretch" />
                <Controls:SecondControl VerticalAlignment="Stretch" />
                <Controls:ThirdControl VerticalAlignment="Stretch" />
            </GridView>
        </SemanticZoom.ZoomedInView>
        <SemanticZoom.ZoomedOutView>
            <GridView SelectionMode="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
            </GridView>
        </SemanticZoom.ZoomedOutView>
    </SemanticZoom>

控件宽度将由其子级处理,但高度必须是GridView的完整大小,如何实现?

1 个答案:

答案 0 :(得分:0)

取代

ItemsPanel to:

<GridView.ItemsPanel>
    <ItemsPanelTemplate>
        <VirtualizingStackPanel Orientation="Horizontal"/>
    </ItemsPanelTemplate>
</GridView.ItemsPanel>

像魅力一样工作