2016-10-19 8 views
0

각 행이 선반을 나타내는 UWP 페이지에서 Grid 및 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의 한계를 설정할 수 있다고 생각하지 않습니다.

원하는 것을 얻을 수있는 한 가지 방법은 오버플로 행을 첫 번째 및 마지막 그리드 행에 넣고 ScrollViewer 경계 밖으로 변환하여 오버 스캔 할 때 표시되도록하는 것입니다.

<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에 대한 세부 사항을 알 수 없기 때문에, 나는 당신이 그렇게 이유가 있지 가정합니다.