2016-04-04 102 views
0

你好,我有這個頁面XAML。問題是每個PivotItem中的文本不能正確滾動,只是滾動一點,但不滾動到最後。樞軸工作正常,您可以翻轉項目水平。我如何才能在滾動條上實現正確的行爲?ScrollView裏面的數據透視項沒有完全滾動

<StackPanel> 
<Pivot> 
    <PivotItem> 
     <ScrollViewer VerticalScrollMode="Enabled"> 
      <StackPanel Margin="0,0,12,0"> 
       <TextBlock HorizontalAlignment="Left" 
           TextWrapping="WrapWholeWords" 
           Foreground="#5D5B5D" 
           FontWeight="Light" 
           TextAlignment="Justify" 
           Margin="0,0,12,0" 
           Padding="0,0,4,0" 
           Text="Change for this a very large text so it can scroll!!! "></TextBlock> 
       <Button Content="OK" 
          HorizontalAlignment="Center" 
          Margin="0,18" 
          Padding="42,4"></Button> 
      </StackPanel> 
     </ScrollViewer> 
    </PivotItem> 
    <PivotItem> 
     <ScrollViewer VerticalScrollMode="Enabled"> 
      <StackPanel Margin="0,0,12,0"> 
       <TextBlock HorizontalAlignment="Left" 
           TextWrapping="WrapWholeWords" 
           Foreground="#5D5B5D" 
           FontWeight="Light" 
           TextAlignment="Justify" 
           Margin="0,0,12,0" 
           Padding="0,0,4,0" 
           Text="Change for this a very large text so it can scroll!!! "></TextBlock> 
       <Button Content="OK" 
          HorizontalAlignment="Center" 
          Margin="0,18" 
          Padding="42,4"></Button> 
      </StackPanel> 
     </ScrollViewer> 
    </PivotItem> 
</Pivot> 

回答

1

從你的代碼,我看到你使用StackPanelPivot控制的,而你沒有設置orientation屬性,因此在默認情況下的垂直堆棧StackPanel項目由上到下它們的聲明順序。這將影響其內部的垂直滾動模式ScrollViewer

一個ScrollViewer作品時,其含量的大小比ScrollViewer的大小,當ScrollViewerStackPanel裏面,它沒有大小的限制,規模將適合的它裏面的孩子大,所以不能在ScrollViewer正常工作。

在這種情況下,你可以在外面StackPanelPivot更改爲Grid,它會解決這個問題,或者你可以給你ScrollViewer類似s <ScrollViewer VerticalScrollMode="Enabled" Height="300">極限高度,這也可以解決問題。

+0

我已經使用父網格,而不是你建議的堆棧面板。現在滾動查看器正常工作,謝謝。我使用網格的行來嵌套/堆疊樞軸和其他需要的視圖。 – Xaren

+0

@Xaren,這是一個很好的解決方案,歡迎您。 –

相關問題