Prajith
Prajith

Reputation: 107

windows phone 8 scrollview not scrolling to the bottom

my windows phone scrollview is not scrolling to the bottom. it bouns back to the top also. please see the code below.

<phone:PhoneApplicationPage
    x:Class="mysample.servicedet"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="False"  
   >


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

        <!--TitlePanel contains the name of the application and page title-->
        <Grid x:Name="TitlePanel" Grid.Row="0" Margin="0,0,0,28" Background="#FFDA251D">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="40"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="80"/>
            </Grid.ColumnDefinitions>
            <Image x:Name="btn_trk_back"  Grid.Row="0" Grid.Column="0" Source="/Assets/other/back-arrow.png" Tap="btn_trk_back_click"  />
            <Image Grid.Row="0" Grid.Column="2"  Source="/Assets/other/logo.png"  Width="70"/>
            <TextBlock Text="Service" Grid.Row="0" Grid.Column="1" Margin="9,0,0,0" Style="{StaticResource PhoneTextTitle1Style}" FontSize="64"/>
        </Grid>


        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1"   Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>            
                <StackPanel Grid.Row="0" Grid.Column="0"  Height="40"   VerticalAlignment="Top" HorizontalAlignment="Stretch"  Background="#FFDA251D">
                    <TextBlock HorizontalAlignment="Center" Text="" x:Name="txtHeading"  Foreground="White" FontSize="28" FontFamily="Segoe WP Semibold" />
                </StackPanel>
            <ScrollViewer Name="ScrollViewer" Grid.Row="1" Grid.Column="0" Height="Auto" >

                <TextBlock HorizontalAlignment="Stretch" TextWrapping="Wrap" Text="" x:Name="txtComment"  Foreground="Black" FontSize="26" FontFamily="Segoe WP"/>

             </ScrollViewer>
        </Grid> 
        </Grid>
</phone:PhoneApplicationPage>

i have to dynamically populate content to txtComment on onnavigated event.

protected override void OnNavigatedTo(NavigationEventArgs e) {
txtComment="Bears are mammals of the family Ursidae. Bears are classified as caniforms, or doglike carnivorans, with the pinnipeds being their closest living relatives. Although only eight species of bears are extant, they are widespread, appearing in a wide variety of habitats throughout the Northern Hemisphere and partially in the Southern Hemisphere. Bears are found on the continents of North America, Central America, South America, Europe, and Asia. " +
                    "Common characteristics of modern bears include large bodies with stocky legs, long snouts, shaggy hair, plantigrade paws with five nonretractile claws, and short tails. While the polar bear is mostly carnivorous and the giant panda feeds almost entirely on bamboo, the remaining six species are omnivorous, with varied diets. " +
                    "With the exceptions of courting individuals and mothers with their young, bears are typically solitary animals. They are generally diurnal, but may be active during the night (nocturnal) or twilight (crepuscular), particularly around humans. Bears are aided by an excellent sense of smell, and despite their heavy build and awkward gait, they can run quickly and are adept climbers and swimmers. In autumn, some bear species forage large amounts of fermented fruits, which affects their behaviour.[1] Bears use shelters, such as caves and burrows, as their dens; most species occupy their dens during the winter for a long period (up to 100 days) of sleep similar to hibernation.[2] " +
                    "Bears have been hunted since prehistoric times for their meat and fur. With their tremendous physical presence and charisma, they play a prominent role in the arts, mythology, and other cultural aspects of various human societies. In modern times, the bears' existence has been pressured through the encroachment on their habitats and the illegal trade of bears and bear parts, including the Asian bile bear market. The IUCN lists six bear species as vulnerable or endangered, and even least concern species, such as the brown bear, are at risk of extirpation in certain countries. The poaching and international trade of these most threatened populations are prohibited, but still ongoing. ";
}

i have reffered many articles, but didnot work for me.

Upvotes: 0

Views: 366

Answers (1)

user3007447
user3007447

Reputation: 400

<Grid x:Name="ContentPanel" Grid.Row="1"   Margin="12,0,12,0">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions> 

Instead of setting the second RowDefinition to Auto, set it to * to take up the rest of the space left in the ContentPanel grid. Setting it to Auto causes it to extend as much as it needs to fit its contents. You don't want it to extend.

Upvotes: 1

Related Questions