使用ScrollViewer时,发现如果包含在Grid里,可以显示出滚动条;
但是放到StackPanel里,为什么就显示不了?
1.放在StackPanel中
<StackPanel>
<ScrollViewer Margin="0" VerticalScrollBarVisibility="Auto">
<StackPanel Margin="0">
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
</StackPanel>
</ScrollViewer>
</StackPanel>
2.放在Grid中
<Grid>
<ScrollViewer Margin="0" VerticalScrollBarVisibility="Auto">
<StackPanel Margin="0">
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
</StackPanel>
</ScrollViewer>
</Grid>