Windows phone 7 ScrollViewer在WP7上向后滚动
我已经创建了一个页面,其中有很多来自用户的输入。因此,用户应该能够向下滚动,以便能够按下上载按钮。为了在页面上向下滚动,我在网格外使用了ScrollViewer。我可以滚动,但页面在向下滚动后会一直向后滚动 这是我的密码:Windows phone 7 ScrollViewer在WP7上向后滚动,windows-phone-7,grid,scrollviewer,Windows Phone 7,Grid,Scrollviewer,我已经创建了一个页面,其中有很多来自用户的输入。因此,用户应该能够向下滚动,以便能够按下上载按钮。为了在页面上向下滚动,我在网格外使用了ScrollViewer。我可以滚动,但页面在向下滚动后会一直向后滚动 这是我的密码: <!--ContentPanel - place additional content here--> <Grid x:Name="ContentPanelButtom" Grid.Row="1" > <
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanelButtom" Grid.Row="1" >
<ScrollViewer >
<Grid x:Name="ContentPanel" Background="black">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="154" />
<ColumnDefinition Width="326" />
</Grid.ColumnDefinitions>
<Image Height="109" HorizontalAlignment="Left" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="167" Margin="23,19,0,0" Source="{Binding Path=ImageSoruce, Mode=TwoWay}" Grid.ColumnSpan="2" />
<TextBox Height="71" HorizontalAlignment="Left" Margin="12,161,0,0" Name="nameInput" Text="{Binding Path=Name, Mode=TwoWay}" VerticalAlignment="Top" Width="430" Grid.ColumnSpan="2" />
<TextBlock Height="56" HorizontalAlignment="Left" Margin="23,134,0,0" Name="nameLabel" Text="Name" VerticalAlignment="Top" Width="130" FontSize="25" />
<TextBlock FontSize="25" Height="60" HorizontalAlignment="Left" Margin="23,238,0,0" Name="descriptionLabel" Text="Description" VerticalAlignment="Top" Width="130" />
<TextBox Height="72" HorizontalAlignment="Left" Margin="12,265,0,0" Name="descriptionInput" Text="{Binding Path=Description, Mode=TwoWay}" VerticalAlignment="Top" Width="430" IsEnabled="True" Grid.ColumnSpan="2" />
<TextBlock FontSize="25" Height="60" HorizontalAlignment="Left" Margin="23,343,0,0" Name="locationLabel" Text="Location" VerticalAlignment="Top" Width="130" />
<TextBlock Height="46" HorizontalAlignment="Left" Margin="24,384,0,0" Name="locationInput" Text="{Binding Path=Location, Mode=TwoWay}" VerticalAlignment="Top" Width="401" Loaded="locationInput_Loaded" Grid.ColumnSpan="2" />
<toolkit:ListPicker SelectionMode="Multiple" FullModeHeader="CATEFORIES" x:Name="ListPickerCategories" CacheMode="BitmapCache" HorizontalAlignment="Left" Margin="25,492,0,0" VerticalAlignment="Top" Width="401" Grid.ColumnSpan="2" ItemsSource="{Binding Categories}" Height="78"></toolkit:ListPicker>
<TextBlock FontSize="25" Height="60" HorizontalAlignment="Left" Margin="24,436,0,0" Name="textBlock1" Text="Categories" VerticalAlignment="Top" Width="130" />
<Button Content="Upload" Height="86" HorizontalAlignment="Left" Margin="26,604,0,0" Name="UploadButton" VerticalAlignment="Top" Width="411" Click="UploadButton_Click" Grid.ColumnSpan="2" />
</Grid>
</ScrollViewer>
</Grid>
这个问题的原因是什么?我该如何解决 使用
StackPanels
将一个元素置于另一个元素之下。删除所有的边距
、高度
、宽度
和其他绝对定位内容
<Grid x:Name="ContentPanelButtom" Grid.Row="1" >
<ScrollViewer>
<StackPanel>
<!-- elements here -->
</StackPanel>
</ScrollViewer>
</Grid>
我也有同样的问题。但最后我解决了它,我只是用Height属性来做这个。请执行以下步骤
- 首先创建一个ScrollViewer
- 指示ScrollViewer创建一个容器(例如:网格/堆栈面板/边框等),并将每个控件放入其中
- 为ScrollViewer和容器设置固定高度(注意:容器的高度应大于ScrollViewer的高度)
<ScrollViewer Height="500">
<Grid Name="Container" Height="700">
<TextBox/>
<TextBox/>
<TextBox/>
</Grid>
</ScrollViewer>
现在,您可以滚动容器网格,甚至可以滚动显示的键盘,甚至可以将焦点放在文本框上