2016-10-19 5 views
0

私は、各行がシェルフを表すUWPページのグリッドとScrollViewerで作業しています。私はN行を持っていますが、最初の行の終わりと最後の行の終わりの間にScrollViewerの制限を設定する必要があります。なぜなら、これらは画面外にあるからです(ユーザーが私は彼に背景を見せたくありませんが、代わりに空の行があります)。uwp scrollViewer set limits

ScrollViewerの上限と下限を指定する方法はありますか?

この

は、私はこれらの要素を定義するXAMLです:

<ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Hidden" Name="MyScrollViewer"> 
    <Grid Name="MyGrid" Tapped="HideOptionMenu"> 
     <Grid.RowDefinitions> 
     </Grid.RowDefinitions> 
    </Grid> 
</ScrollViewer> 

行が実行時に動的に追加されているので、行の数は必ずしも同じではありません。また、画面のサイズを変更すると、各行の高さが変わります。

お時間をいただきありがとうございます。

答えて

0

ScrollViewerの制限を設定することはできません。

あなたが望むものを達成できる方法の1つは、最初のグリッド行と最後のグリッド行にオーバースクロール行を置き、スクロールビューアーの境界の外にそれらを翻訳してオーバースクロール時に表示されるようにすることです。

<ScrollViewer> 
    <Grid> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="100"/> 
      <RowDefinition Height="100"/> 
      <RowDefinition Height="100"/> 
      <RowDefinition Height="100"/> 
      <RowDefinition Height="100"/> 
      <RowDefinition Height="100"/> 
      <RowDefinition Height="100"/> 
      <RowDefinition Height="100"/> 
     </Grid.RowDefinitions> 

     <!-- Top overscroll row --> 
     <Rectangle Grid.Row="0" HorizontalAlignment="Stretch" Fill="Orange" Stroke="Black"> 
      <Rectangle.RenderTransform> 
       <TranslateTransform Y="-100"/> 
      </Rectangle.RenderTransform> 
     </Rectangle> 

     <!-- Bottom overscroll row --> 
     <Rectangle Grid.Row="8" HorizontalAlignment="Stretch" Fill="Orange" Stroke="Black"> 
      <Rectangle.RenderTransform> 
       <TranslateTransform Y="100"/> 
      </Rectangle.RenderTransform> 
     </Rectangle> 

     <Rectangle Grid.Row="0" HorizontalAlignment="Stretch" Fill="Red" Stroke="Black"/> 
     <Rectangle Grid.Row="1" HorizontalAlignment="Stretch" Fill="Red" Stroke="Black"/> 
     <Rectangle Grid.Row="2" HorizontalAlignment="Stretch" Fill="Red" Stroke="Black"/> 
     <Rectangle Grid.Row="3" HorizontalAlignment="Stretch" Fill="Red" Stroke="Black"/> 
     <Rectangle Grid.Row="4" HorizontalAlignment="Stretch" Fill="Red" Stroke="Black"/> 
     <Rectangle Grid.Row="5" HorizontalAlignment="Stretch" Fill="Red" Stroke="Black"/> 
     <Rectangle Grid.Row="6" HorizontalAlignment="Stretch" Fill="Red" Stroke="Black"/> 
     <Rectangle Grid.Row="7" HorizontalAlignment="Stretch" Fill="Red" Stroke="Black"/> 
     <Rectangle Grid.Row="8" HorizontalAlignment="Stretch" Fill="Red" Stroke="Black"/> 
    </Grid> 
</ScrollViewer> 

それは本当にのStackPanel/ListViewコントロールのレイアウトである何のためにグリッドを使用して少し不器用な感じが、私はあなたのUIについての詳細を知っていないので、私はあなたがそうする理由を持っていると仮定します。