0

在我的应用程序中,我有一个 StackPanel,其方向设置为“水平”。在我的 StackPanel 中有 4 个图像。当我尝试水平滚动此内容时,它只滚动几个像素,我看不到整个内容。当我将 StackPanel 的方向更改为垂直时,我可以垂直滚动整个内容。为什么它不可能 hotizontally 滚动它?有什么想法可以解决这个问题吗?

<Grid>
        <ScrollViewer>
            <StackPanel Orientation="Horizontal" >
                <Canvas Margin="120,0,0,0"
                        Width="310"
                        Height="390">
                    <Image Width="310"
                           Height="390" 
                           Source="ms-appx:///Assets/Image/background_teaser.png"/>
                </Canvas>

                <Canvas Margin="120,0,0,0"
                        Width="310"
                        Height="390">
                    <Image Width="310"
                           Height="390" 
                           Source="ms-appx:///Assets/Image/background_teaser.png"/>
                </Canvas>

                <Canvas Margin="120,0,0,0"
                        Width="310"
                        Height="390">
                    <Image Width="310"
                           Height="390" 
                           Source="ms-appx:///Assets/Image/background_teaser.png"/>
                </Canvas>

                <Canvas Margin="120,0,0,0"
                        Width="310"
                        Height="390">
                    <Image Width="310"
                           Height="390" 
                           Source="ms-appx:///Assets/Image/background_teaser.png"/>
                </Canvas>
            </StackPanel>
        </ScrollViewer>
    </Grid
4

2 回答 2

3

默认情况下不启用水平滚动。

<ScrollViewer HorizontalScrollMode="Auto" HorizontalScrollBarVisibility="Auto">
于 2013-07-11T09:18:43.210 回答
0

我在 ScrollViewer 中使用 Stackpanels 时遇到了一些问题。尝试将 Stackpanel 包装在另一个 Grid 中。正如其他人指出的那样,您需要在 ScrollViewer 上设置 Horizo​​ntalScrollMode

于 2013-07-11T11:54:38.227 回答