简体   繁体   中英

Auto SnapBack with scrollviewer on WP7

Hi everyone i'm having problem with my scrolling , it always snaps back can someone help me out with finding the error :) THanks! Updated , still not working

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Height="954" Background="White">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" MinHeight="45"/>
        <RowDefinition/>
    </Grid.RowDefinitions>

    <!--TitlePanel contains the name of the application and page title-->

    <!--ContentPanel - place additional content here-->
    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Margin="12,17,0,28" />
    <!--ContentPanel - place additional content here-->
    <ScrollViewer HorizontalAlignment="Left" x:Name="scrollViewer1" VerticalAlignment="Stretch" Width="465" Margin="-9,0,0,0">
        <Grid x:Name="ContentPanel" Margin="12,8,12,-226" Grid.RowSpan="2" >

            <Grid Height="986" Margin="6,2,-37,730">
                <Grid.RowDefinitions>
                    <RowDefinition Height="832*" />
                    <RowDefinition Height="154*" />
                </Grid.RowDefinitions>
                <StackPanel x:Name="stackPanel1" Margin="16,116,227,0" d:LayoutOverrides="HorizontalAlignment" Grid.RowSpan="2"></StackPanel>
                <StackPanel x:Name="stackPanel2" Margin="0,173,9,-11" HorizontalAlignment="Right" Width="207" Grid.RowSpan="2"></StackPanel>
                <Rectangle Height="50" HorizontalAlignment="Left" Margin="-26,33,0,0" Name="rectangle1" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="359" Fill="#FFFF57CB" />
                <TextBlock Height="51" HorizontalAlignment="Left" Margin="24,33,0,0" Name="textBlock1" Text="Case Taking" VerticalAlignment="Top" Width="311" FontWeight="SemiBold" FontSize="32" />
            </Grid>

        </Grid>
    </ScrollViewer>
</Grid>

Remove the Height="..." from your ScrollViewer and change it to VerticalAlignment="Stretch"

The ScrollViewer will scroll it's content. What you are doing, is giving ScrollViewer a large size (with the Height) and thus it thinks it does not need to scroll.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM