我正在开发一个Windows phone8.1Runtime应用程序,我使用的ListView
只有GroupStyle
和它的HeaderTemplate
集。
一切正常,除了我需要禁用粘性标题,它在滚动列表时总是在顶部,但我找不到我需要编辑哪个模板来完全禁用粘性标题。真正困扰我的一件事是,当我离开页面时,当前的页眉消失了,并且在同一位置出现了一个空白。
代码很简单:
<CollectionViewSource
x:Key="cvs"
IsSourceGrouped="True"
ItemsPath="GroupItems"
Source="{Binding Categories}">
</CollectionViewSource>
在Resource
中,
和ListView
<ListView
x:Name="ListView"
IsSwipeEnabled="False"
ItemTemplateSelector="{StaticResource AllGamesViewTemplateSelector}"
ItemsSource="{Binding Source={StaticResource cvs}}"
SelectionMode="None"
ShowsScrollingPlaceholders="True">
<ListView.GroupStyle>
<GroupStyle HeaderTemplate="{StaticResource AllGamesViewCategoryTemplate}"/>
</ListView.GroupStyle>
</ListView>
所以我的问题是如何在分组的ListView
上禁用粘性标头
发布于 2017-01-27 01:27:17
我也有同样的问题,最后遇到了这个:https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.itemsstackpanel.arestickygroupheadersenabled?f=255&MSPPError=-2147217396
在列表视图的ItemsPanelTemplate中设置AreStickyGroupHeadersEnabled属性。
<ListView
x:Name="ListView"
IsSwipeEnabled="False"
ItemTemplateSelector="{StaticResource AllGamesViewTemplateSelector}"
ItemsSource="{Binding Source={StaticResource cvs}}"
SelectionMode="None"
ShowsScrollingPlaceholders="True">
<ListView.GroupStyle>
<GroupStyle HeaderTemplate="{StaticResource AllGamesViewCategoryTemplate}"/>
</ListView.GroupStyle>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsStackPanel AreStickyGroupHeadersEnabled="False"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
发布于 2014-12-05 00:24:50
您应该能够将ListView包装在ScrollViewer中,以防止粘性标题。
发布于 2016-01-06 19:14:21
我想到的一个解决方案不是在ListView中使用分组,而是模拟它。创建一个集合,该集合将包含组的项和表示标头的占位符项。然后使用ListView的模板选择器将占位符项呈现为标题。
https://stackoverflow.com/questions/26393335
复制相似问题