Matapolo
Matapolo

Reputation: 667

Cannot scroll content horizontal in windows store app

In my application, I have a StackPanel with the Orientation set to 'horizontal'. In my StackPanel there are 4 Images. When I try to scroll this content horizontally, it only scrolls a few pixels and I cannot see the whole content. When I change the Orientation of my StackPanel to vertical, I can scroll my whole content vertical. Why it isn't possible to scroll it hotizontally? Any ideas how I can solve this problem?

<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

Upvotes: 0

Views: 2280

Answers (2)

Thomas
Thomas

Reputation: 4297

I had some issues working with Stackpanels in a ScrollViewer. Try wrapping the Stackpanel in another Grid. And as the others have pointed out, you need to set the HorizontalScrollMode on your ScrollViewer

Upvotes: 0

Sebastian Negraszus
Sebastian Negraszus

Reputation: 12205

Horizontal scrolling is not enabled per default.

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

Upvotes: 3

Related Questions