Json Listbox的滚动事件
我已经调用了json请求&它一次调用会给我20个项目。我已经在我的页面中设置了这20个项目,但实际上项目总数是1000,现在我想调用另外20个数据,并在滚动后加载到同一页面中,所以我必须处理scrollviewer的哪个事件,以便管理一个页面中的所有项目 列表框看起来像:Json Listbox的滚动事件,json,windows-phone-8,listbox,Json,Windows Phone 8,Listbox,我已经调用了json请求&它一次调用会给我20个项目。我已经在我的页面中设置了这20个项目,但实际上项目总数是1000,现在我想调用另外20个数据,并在滚动后加载到同一页面中,所以我必须处理scrollviewer的哪个事件,以便管理一个页面中的所有项目 列表框看起来像: <ListBox Name="lstSubNews" Grid.Row="1" SelectionChanged="lstSubNews_SelectionChanged" ScrollViewer.
<ListBox Name="lstSubNews" Grid.Row="1" SelectionChanged="lstSubNews_SelectionChanged"
ScrollViewer.VerticalScrollBarVisibility="Visible" Style="{StaticResource ListColor}">
<ListBox.ItemTemplate>
<DataTemplate>
<Border Margin="5,0.8,5,0.8">
<StackPanel Orientation="Vertical" Height="90" Width="500" Background="AliceBlue" >
<Grid >
<Grid.RowDefinitions >
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="420"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding subject}"Grid.Row="0" Grid.Column="0"></TextBlock>
<TextBlock Text="{Binding poster}" Grid.Row="1" Grid.Column="0" ></TextBlock>
</Grid>
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
滚动查看器,它位于ListBox模板内,并处理ListBox的ValueChanged事件,该事件在滚动开始时立即发生。您可以提取滚动查看器,然后检测用户何时滚动到底部
var border=(visualtreeheloper.GetChild(lstSubNews,0)作为边框);
ScrollViewer ScrollViewer=border.Child作为ScrollViewer;
scrollViewer.ViewChanged+=异步(a,t)=>
{
如果(scrollViewer.VerticalOffset>scrollViewer.ScrollableHeight-5)
{
//代码在这里
}
};
但是,正确的方法是实现ISupportIncrementalLoading
接口:
@Pradeep Kesharwani如果你能举个例子的话?@Viraj在这里我只是给你一个解决问题的想法你有一个web服务可以给你20个项目作为响应,而我没有这样的web服务,这样我就无法为你应用它作为演示