2013-10-01 83 views
0

在模擬器模式下測試,即使我有100條記錄要顯示,GridView不會垂直滾動,但它顯示一個垂直條,但不能用於滾動。我需要做些什麼來使它垂直滾動或水平滾動?如何使GridView控件垂直滾動或水平滾動

您對此問題的幫助表示讚賞。感謝

 
<GridView x:Name="CustomersGridView" 
    Grid.Row="1" 
    Margin="37,174,73,89" 
    Foreground="White"  
    SelectionMode="Single" 
    IsSwipeEnabled="True" 
    IsItemClickEnabled="True" 
    ItemsSource="{Binding Mode=OneWay, Source={StaticResource CustomersViewSource}}" 
    ItemTemplate="{StaticResource CustomerTemplate}" 
    ItemClick="CustomersGridView_ItemClick" 

    // Horizontal or vertical here:   
    ScrollViewer.HorizontalScrollBarVisibility="Auto" 

    SelectionChanged="CustomersGridView_SelectionChanged"> 

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

</GridView> 



回答

2

裹在一個ScrollViewer

例如控制:

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     WindowTitle="ScrollViewer Sample"> 
    <ScrollViewer HorizontalScrollBarVisibility="Auto"> 
    <StackPanel VerticalAlignment="Top" HorizontalAlignment="Left"> 
     <TextBlock TextWrapping="Wrap" Margin="0,0,0,20">Scrolling is enabled when it is necessary. 
     Resize the window, making it larger and smaller.</TextBlock> 
     <Rectangle Fill="Red" Width="500" Height="500"></Rectangle> 
    </StackPanel> 
    </ScrollViewer> 
</Page>