2017-03-31 68 views
1

我創建了一種簿記器,並希望使每個部分水平滾動(有點像ibooks)。我試圖用ScrollViewer來包裝我的Gridview,但那樣搞砸了。感謝幫助!這裏是我的代碼片段:UWP - 網格視圖內水平滾動視圖

<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> 

回答

2

我認爲這是你正在尋找

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

謝謝哥們的事兒!我添加Grid.Row到我的scrollviewer(包裹我的gridview),它的工作!我也嘗試了你的建議(用GridView.ItemsPanel替換GridView.ItemTemplate),但不支持DataTemplate – AnneP

+0

看起來你不需要移除可以添加'GridView.ItemsPanel'的'GridView.ItemTemplate'。 –