【发布时间】:2014-07-23 22:01:06
【问题描述】:
我正在实现一个 RSS 阅读器应用程序,并且我正在使用 ItemsControl 来显示新闻项目。我试图像这样在 ItemsControl 下方添加一个“加载更多”按钮
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<ItemsControl x:Name="itemsControl" Margin="10,10,10,0" Grid.Row="0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel>
</VirtualizingStackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.Template>
<ControlTemplate TargetType="ItemsControl">
<ScrollViewer>
<ItemsPresenter />
</ScrollViewer>
</ControlTemplate>
</ItemsControl.Template>
</ItemsControl>
<TextBlock x:Name="loadMoreTextBlock" Grid.Row="1" Text="Load more"/>
</Grid>
但文本块不会在滚动结束时显示,并且始终在根网格中可见。当用户向下滚动到底部时,我只想在项目控件的末尾显示“加载更多”文本。
像这样更改 ItemsControl.Template
<ItemsControl.Template>
<ControlTemplate TargetType="ItemsControl">
<ScrollViewer>
<StackPanel>
<ItemsPresenter />
<TextBlock x:Name="loadMoreTextBlock" Text="Load more"/>
</StackPanel>
</ScrollViewer>
</ControlTemplate>
</ItemsControl.Template>
解决了问题,但是ItemsControl的性能很差。您有更好的想法或建议吗?
谢谢 维诺特·塞尔瓦拉杰
【问题讨论】:
标签: silverlight windows-phone-8.1 itemscontrol