我在扩展器面板内部有一个堆栈面板,我编写了复选框。目前,exanpander停在窗体的底部,但堆栈面板不断增长。我希望堆栈面板由扩展器限制并滚动以显示复选框。我是否需要在列表框中设置复选框才能获得滚动功能?
<Grid>
<Expander Header="Expander1" Margin="0,0,0,2" Name="Expander1" VerticalAlignment="Top" Background="Coral">
<StackPanel Name="StackScroll" Margin="0,0,0,2" Background="Aqua"></StackPanel>
</Expander>
</Grid>
“);
答案 0 :(得分:9)
您可以将StackPanel嵌套在ScrollViewer中:
<Grid>
<Expander Header="Expander1" Margin="0,0,0,2" Name="Expander1" VerticalAlignment="Top" Background="Coral">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel Name="StackScroll" Margin="0,0,0,2" Background="Aqua">
</StackPanel>
</ScrollViewer>
</Expander>
</Grid>
答案 1 :(得分:2)
在StackPanel声明中设置 ScrollViewer.VerticalScrollBarVisibility =“Auto”。