UWP - 网格视图内的水平可滚动视图

时间:2017-03-31 22:03:39

标签: uwp uwp-xaml

我正在创建一种簿记员,并希望每个部分都可以水平滚动(有点像ibooks)。我试图用Gridview包裹我的ScrollViewer,但这搞砸了。感谢帮助!这是我的代码段:

<ScrollViewer Margin="10,0,0,0">
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="5,10,5,5">
        <Grid.RowDefinitions>
            <RowDefinition Height="60"/>
            <RowDefinition Height="30"/>
        </Grid.RowDefinitions>
        <TextBlock Text="Romances" FontSize="18"/>           
        <GridView Name="JuvenileBooks"  Grid.Row="1"
                  HorizontalAlignment="Stretch" 
                  VerticalAlignment="Stretch" >
            <GridView.ItemTemplate>
                <DataTemplate x:DataType="data:BookModel">
                    <local:BookshelvesDataTemplate/>
                </DataTemplate>
            </GridView.ItemTemplate>
        </GridView>
</ScrollViewer>

1 个答案:

答案 0 :(得分:2)

我认为这是你要找的东西

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