silverlight – 在ListBox的末尾添加一个Load More按钮而不会丢失虚拟化?

silverlight – 在ListBox的末尾添加一个Load More按钮而不会丢失虚拟化?,第1张

概述我知道通过编辑ListBox的默认样式,我可以在ListBox的最后有一个Button. <ScrollViewer x:Name="ScrollViewer" ...> <StackPanel> <ItemsPresenter /> <Button /> </StackPanel></ScrollViewer> 但是,这样做会破坏ListBox 我知道通过编辑ListBox的默认样式,我可以在ListBox的最后有一个button.

@H_403_11@<ScrollVIEwer x:name="ScrollVIEwer" ...> <StackPanel> <ItemsPresenter /> <button /> </StackPanel></ScrollVIEwer>

但是,这样做会破坏ListBox的虚拟化,渲染时间变得非常长.

我能想到的只是,

>创建一个虚拟项目并将其添加到我的项目集合的末尾
viewmodel,在虚拟对象中有一个名为buttonGrIDVisibility的Visibility属性,并将其设置为Visibility.Visible.
>在我的ListBox的ItemTemplate中,有两个网格.一显示
正常的项目布局,另一个显示加载更多按钮.
然后根据buttonGrIDVisibility属性切换其Visibility.

这可能有用,但我只是想知道是否有更简单/更好的方法?

解决方法 我知道这是一个老帖子,但万一有些人偶然发现:

有一个LongListSelector控件available out of the box in WP8或作为WP001的Windows Phone Toolkit的一部分,它非常巧妙地支持这个场景.如果要在最后一个项目之后(或在第一个项目之前)添加特定内容,则只需设置控件的ListFooter或Listheader即可.您可以在其中放置任何内容,此内容将与其他项目一起滚动.

所以对于WP7,这看起来像这样:

@H_403_11@<toolkit:LongListSelector ItemsSource="{Binding Items}"> <toolkit:LongListSelector.ListFooter> <GrID> <button /> </GrID> </toolkit:LongListSelector.ListFooter></toolkit:LongListSelector>

其中toolkit是xmlns:toolkit =“clr-namespace:Microsoft.Phone.Controls; assembly = Microsoft.Phone.Controls.Toolkit”

总结

以上是内存溢出为你收集整理的silverlight – 在ListBox的末尾添加一个Load More按钮而不会丢失虚拟化?全部内容,希望文章能够帮你解决silverlight – 在ListBox的末尾添加一个Load More按钮而不会丢失虚拟化?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1004757.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存