LongListSelector 控件拉伸事件未触发
我一直在尝试将代码附加到 LongListSelector 的 StretchingBottom 事件,但没有成功。这是 XAML 中的定义
<toolkit:LongListSelector x:Name="NewList"
IsFlatList="True"
IsBouncy="True"
Background="Transparent"
ShowListFooter="False"
ShowListHeader="{Binding ProgressBar}"
Margin="0,0,12,0"
ListHeaderTemplate="{StaticResource progressbarListHeader}"
ItemsSource="{Binding Items}"
ItemTemplate="{StaticResource Item}"
SelectionChanged="List_SelectionChanged"
StretchingBottom="List_StretchingBottom"/>
这是 List_SelectionChanged 方法:
private void List_StretchingBottom(object sender, EventArgs e)
{
var listbox = (LongListSelector)sender;
var viewModel = (ItemsViewModel)listbox.DataContext;
viewModel.LoadDataAfter();
}
当我在方法的第一行放置断点时,即使我一直延伸或等待,它也永远不会被击中。我尝试过 StretchingTop 和 StretchingComplete 但没有成功。
有人可以帮忙吗?
I've been trying to attach code to the StretchingBottom event of a LongListSelector with no success. This is the definition in XAML
<toolkit:LongListSelector x:Name="NewList"
IsFlatList="True"
IsBouncy="True"
Background="Transparent"
ShowListFooter="False"
ShowListHeader="{Binding ProgressBar}"
Margin="0,0,12,0"
ListHeaderTemplate="{StaticResource progressbarListHeader}"
ItemsSource="{Binding Items}"
ItemTemplate="{StaticResource Item}"
SelectionChanged="List_SelectionChanged"
StretchingBottom="List_StretchingBottom"/>
This is the method List_SelectionChanged:
private void List_StretchingBottom(object sender, EventArgs e)
{
var listbox = (LongListSelector)sender;
var viewModel = (ItemsViewModel)listbox.DataContext;
viewModel.LoadDataAfter();
}
When I put a breakpoint on the first line of the method it never gets hit even if I stretch all the way or wait. I've tried StretchingTop and StretchingComplete with no success.
Anyone can help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚在 MSDN 博客 和 Codeplex
有 ScrollViewer 的示例,但 LongListSelector 正在使用 ScrollViewer...
第一:将模板添加到 Application.Resources 内的 App.XAML
:
这将启用压缩的视觉状态组,因此您可以检测列表滚动到末尾时出现的压缩。您需要 CompressionBottom,因为当列表滚动到底部时会发生这种情况。
现在,我将一个处理程序附加到 LongListSelector.Loaded 事件,并在内部将一个处理程序附加到 ScrollViewer.State
如您所见,我根本不使用 LongListSelector.StretchingBottom 事件。
但它有效:)
I just got this working with much help from a MSDN blog and Codeplex
The examples there are for the ScrollViewer but the LongListSelector is using the ScrollViewer...
1st: add a Template to App.XAML inside the Application.Resources
:
This enables the visual state groups for Compression, so you can detect the Compression that appeares if the list is scrolled to an end. You want CompressionBottom as this happenes when the List is scrolled to the bottom.
Now I attach a handler to the LongListSelector.Loaded event and inside attach a handler to the ScrollViewer.State
As you can see I don't use the LongListSelector.StretchingBottom event at all.
But it works :)