在下面的WPF XAML中,ScrollViewer不起作用(它显示滚动条但不能滚动,内容从窗口向下移动到底部).
我可以将外部StackPanel更改为Grid,它将起作用.
但是,在我复制以下代码的应用程序中,我需要一个外部StackPanel.我需要对StackPanel做什么才能让ScrollViewer显示一个可用的滚动条?例如VerticalAlignment ="Stretch"Height ="Auto"不起作用.
<StackPanel>
<ScrollViewer>
<StackPanel>
<TextBlock Text="This is a test"/>
<TextBlock Text="This is a test"/>
<TextBlock Text="This is a test"/>
<TextBlock Text="This is a test"/>
<TextBlock Text="This is a test"/>
<TextBlock Text="This is a test"/>
<TextBlock Text="This is a test"/>
<TextBlock Text="This is a test"/>
<TextBlock Text="This is a test"/>
<TextBlock Text="This is a test"/>
<TextBlock Text="This is a test"/>
<TextBlock Text="This is a test"/>
<TextBlock Text="This is a test"/>
<TextBlock Text="This is a …Run Code Online (Sandbox Code Playgroud)