我的Windows手机滚动视图没有滚动到底部。它也回到了顶部。请参阅下面的代码。
<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>
我必须在onnavigated事件上动态填充内容到txtComment。
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. ";
}
我已经参考了许多文章,但对我没有用。
答案 0 :(得分:1)
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
不是将第二个RowDefinition设置为Auto,而是将其设置为*以占用ContentPanel网格中剩余的剩余空间。将其设置为“自动”会使其扩展到适合其内容所需的范围。你不希望它扩展。