2014-05-17 49 views

回答

0

您可以在網格中添加一個ScrollViewer,並使您的3x3網格位於水平方向的StackPanel中。

<Grid > 
     <ScrollViewer VerticalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Visible" ScrollChanged="ScrollViewer_ScrollChanged"> 
      <StackPanel Orientation="Horizontal" Name="stack"> 
        ... 
      </StackPanel> 
     </ScrollViewer> 
    </Grid> 

然後使用ScrollViewer_ScrollChanged改變滾動偏移量

private void ScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e) 
    { 
     int direction = e.HorizontalChange > 0 ? 1 : -1; 
     (sender as ScrollViewer).ScrollToHorizontalOffset(stack.ActualWidth * direction/[number of grids]); 

    }