【问题标题】:Cannot scroll content horizontal in windows store app无法在 Windows 商店应用程序中水平滚动内容
【发布时间】:2013-07-11 08:56:49
【问题描述】:

在我的应用程序中,我有一个 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

【问题讨论】:

  • ScrollViewer 的属性Scroll 设置为双向true?

标签: c# visual-studio-2012 windows-8 windows-store-apps winrt-xaml


【解决方案1】:

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

<ScrollViewer HorizontalScrollMode="Auto" HorizontalScrollBarVisibility="Auto">

【讨论】:

  • 请注意,@Matapolo 可能还想禁用垂直滚动:VerticalScrollMode="Disabled" VerticalScrollBarVisibility="Disabled"
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多