在一个父网格下有三个子网格。
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Name="grid1"> </Grid>
<Grid Grid.Row="1" Name="grid2"> </Grid>
<Grid Grid.Row="2" Name="grid3"> </Grid>
</Grid>
如果grid2具有更多数据,则所有三个网格都在滚动。 我希望grid1和grid3的位置应该固定,只有中间网格应该滚动
答案 0 :(得分:1)
如果可以的话,请为grid1和grid3的行高度使用固定的大小值
您可以使用Stackblitz demo
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" VerticalAlignment="Top" Name="grid1"> </Grid>
<Grid Grid.Row="1" Name="grid2">
<ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible">
//Content Here
</ScrollViewer>
</Grid>
<Grid Grid.Row="2" VerticalAlignment="Bottom" Name="grid3"> </Grid>
</Grid>
答案 1 :(得分:1)
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Name="grid1" Margin="10">
<TextBlock Text="Some Data"/>
</Grid>
<Grid Grid.Row="1" Name="grid2" Margin="10">
<ScrollViewer VerticalScrollMode="Auto">
<StackPanel>
<TextBlock Text="Some Data "/>
<TextBlock Text="Some Data "/>
<TextBlock Text="Some Data "/>
<TextBlock Text="Some Data "/>
<TextBlock Text="Some Data "/>
<TextBlock Text="Some Data "/>
<TextBlock Text="Some Data "/>
<TextBlock Text="Some Data "/>
<TextBlock Text="Some Data "/>
<TextBlock Text="Some Data "/>
<TextBlock Text="Some Data "/>
<TextBlock Text="Some Data "/>
<TextBlock Text="Some Data "/>
<TextBlock Text="Some Data "/>
<TextBlock Text="Some Data "/>
<TextBlock Text="Some Data "/>
<TextBlock Text="Some Data "/>
<TextBlock Text="Some Data "/>
</StackPanel>
</ScrollViewer>
</Grid>
<Grid Grid.Row="2" Name="grid3" Margin="10">
<TextBlock Text="Some Data"/>
</Grid>
</Grid>
*您需要将水平/垂直滚动模式设置为自动/启用