1
votes

In mobile version of the Windows UWP Microsoft weather app, there is a scroll viewer to scroll vertically down the page.

However within the page, there is a Daily forecast which can scroll horizontally. I have tried to use a scrollviewer within the vertically scroll viewer on my page, but can never get the content in the horizontal scrollviewer to scroll.

What I have is something like this

<Page ...>

<Grid >

    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition />
    </Grid.RowDefinitions>


    <!--EntranceNavigationTransitionInfo.IsTargetElement="True"-->
    <ScrollViewer  Grid.Row="1"  ScrollViewer.VerticalScrollMode="Enabled"  HorizontalAlignment="Stretch"   VerticalAlignment="Stretch" ViewChanged="ScrollViewer_ViewChanged"  >

        <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Center"  Margin="15,0,15,0" >



            <Grid HorizontalAlignment="Center" Padding="0,0,0,20">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <StackPanel Orientation="Vertical" Grid.Column="0">

                </StackPanel>
            </Grid>



            <Grid HorizontalAlignment="Center">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="Auto" ></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <StackPanel Grid.Column="0" Orientation="Vertical" Padding="0,0,0,0" Margin="0,0,15,0">


                </StackPanel>
                <StackPanel Grid.Column="1" Orientation="Vertical">


                </StackPanel>
            </Grid>

            <RichTextBlock Foreground="White"  Margin="0,20,0,0"   VerticalAlignment="Bottom">

            </RichTextBlock>

            <ScrollViewer Margin="0,20,0,0" HorizontalScrollMode="Enabled" HorizontalAlignment="Stretch" VerticalScrollMode="Disabled" VerticalScrollBarVisibility="Disabled">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">

                    <!--In here i have horizontal row of items that I want the user to scroll horizontally to view them like in the MS Weather app -->

                </StackPanel>
            </ScrollViewer>

        </StackPanel>

    </ScrollViewer>
</Grid>

1

1 Answers

1
votes

I suggest you should add HorizontalScrollBarVisibility="Visible". It's probably because you have a Scrollview inside a Scrollview, there will be a bug right there. It should be like this:

<ScrollViewer Margin="0,20,0,0" HorizontalScrollMode="Enabled" HorizontalAlignment="Stretch" VerticalScrollMode="Disabled" VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Visible">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">

                    <!--In here i have horizontal row of items that I want the user to scroll horizontally to view them like in the MS Weather app -->

                </StackPanel>
            </ScrollViewer>

Hope it helps!