Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf stackpanel中的垂直滚动_Wpf - Fatal编程技术网

Wpf stackpanel中的垂直滚动

Wpf stackpanel中的垂直滚动,wpf,Wpf,我试图得到一个滚动条被放置在堆栈面板上。滚动条显示,但不允许用户移动滚动条。我的XMAL有什么问题吗?还是有更多的问题 <GroupBox HorizontalAlignment="Left" Margin="268,8,0,0" VerticalAlignment="Top" Width="505.881" Height="352.653" Header="Metrics"> <Grid> <ScrollViewer> <Sta

我试图得到一个滚动条被放置在堆栈面板上。滚动条显示,但不允许用户移动滚动条。我的XMAL有什么问题吗?还是有更多的问题

<GroupBox HorizontalAlignment="Left" Margin="268,8,0,0" VerticalAlignment="Top" Width="505.881" Height="352.653" Header="Metrics">
<Grid>
    <ScrollViewer>
        <StackPanel>
              </StackPanel>
          </ScrollViewer>
      </Grid>
</GroupBox>


堆栈面板的内容是包含数据的扩展器。

为了使内部ScrollViewer工作,不能设置GroupBox的宽度和高度。试试这个,你会发现它很好用

<GroupBox Header="Metrics" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="268,8,0,0">
    <Grid>
        <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
            <StackPanel>
                <Expander Header="Expander">
                    <StackPanel>
                        <Button>Test</Button>
                        <Button>Test</Button>
                        <Button>Test</Button>
                        <Button>Test</Button>
                        <Button>Test</Button>
                        <Button>Test</Button>
                        <Button>Test</Button>
                        <Button>Test</Button>
                        <Button>Test</Button>
                    </StackPanel>
                </Expander>

            </StackPanel>
        </ScrollViewer>
    </Grid>
</GroupBox>

试验
试验
试验
试验
试验
试验
试验
试验
试验

ScrollViewer的默认设置是
HorizontalScrollBarVisibility=“Disabled”VerticalScrollBarVisibility=“Visible”
,因此您看到的是ScrollViewer的可见但禁用的状态。如果ScrollViewer的内容变得比可用空间高,垂直条将变成交互式的,并允许滚动。尝试设置VerticalScrollBarVisibility=“Auto”以更清楚地看到它何时处于活动状态。

谢谢,这是否意味着不能在滚动视图内的任何内容上设置宽度或高度?可以在ScrollViewer内设置项目的宽度和高度。因此,在我上面的示例代码中,这意味着可以设置内部StackPanel的宽度或高度。如果你喜欢的话