XAML分组GridView /语义缩放不显示所有孩子?

我正在尝试使用XAML C#Grouped GridView示例使我的SemanticZoom在XAML C#Windows 8应用程序中工作。 问题是,由于某种原因,它显示正确的标题(在这种情况下是类别),但它没有显示标题下的所有项目(它只显示每个项目,当我在其中一些项目中最多有6个项目时)。

这是SemanticZoom的XAML代码(请注意,为了简洁起见,我省略了ZoomedOutView,因为它运行良好):

                                               

以及启动应用程序时调用的Refresh()C#函数:

 System.Collections.ObjectModel.ObservableCollection finalSource = new System.Collections.ObjectModel.ObservableCollection(); public async Task Refresh() { var Pins = await pinTable.ReadAsync(); //pinTable is an Azure Mobile Services table List categoriesMixed = new List(); if (Pins.ToArray().Length < 1) { //adds a new "Welcome" pin to the table, taken out for brevity } foreach (pin nowPin in Pins) { SemanticZoomed toAdd = new SemanticZoomed(); toAdd.Category = nowPin.category; toAdd.pinNumber = nowPin.Id.ToString(); toAdd.Title = nowPin.name; categoriesMixed.Add(nowPin.category); finalSource.Add(toAdd); } List<GroupPinList> groups = new List<GroupPinList>(); var query = from nowPin in finalSource orderby ((SemanticZoomed)nowPin).Category group nowPin by ((SemanticZoomed)nowPin).Category into g select new { GroupName = g.Key, Items = g }; foreach (var g in query) { GroupPinList info = new GroupPinList(); info.Key = g.GroupName; foreach (var item in g.Items) { info.Add(item); } groups.Add(info); } cvs2.Source = groups; (boardZoom.ZoomedOutView as ListViewBase).ItemsSource = cvs2.View.CollectionGroups; return true; } 

以下是groups变量的外观截图,以及生成的SemanticZoom显示的内容:

groups变量:

组变量

groups变量中的“Welcome”类别(它正确地显示了它的6个项目,以及错误“无法获取字段’imgSrc’的值,因为imgSrc旁边的包含类的信息不可用,它在cvs2中消失了) :

欢迎类别

cvs2(它显示欢迎类别下的6个不同项目):

CVS2

最后,它最终显示:

最终结果

我对“欢迎”类别中的其他引脚的位置感到茫然。 我错过了XAML代码中的某些内容吗? 任何帮助将非常感激 :)

我想我知道问题出在哪里 – 如果您在组后以编程方式向GridView添加项目,则会发生这种情况。 这里发生的是当您将第一个包含n个项目的组添加到GridView源时,然后保留数字n,并且对于之后添加的每个组,它显示不超过n个项目,即使有更多项目。

因此,如果您在集合中有5个组以及2,4,1,5,3项,则将空ObservableCollection指定为GridView的ItemSource,然后将这些组添加到ObservableCollection中,您将只看到2,2,每组1,2,2项。

我不知道为什么会发生这种情况,如果它的function或错误,但您可以通过首先加载ObservableCollection然后将其作为源分配给GridView来解决它,或者您可以使用某种转换器,返回每组相同数量的项目。 对于编号较小的组,您可以添加假空项并使用不同的DataTemplate隐藏它们。

编辑:我刚刚注意到你已经立刻添加了这个集合,所以问题可能在其他地方。 也许你的问题根源是ItemsPanel吗?

 MaximumRowsOrColumns="1" 

我也有同样的问题 。 这解决了pb。

在SemanticZoom.ZoomedInView中替换

    

通过

    
 you need to use stackpanel instead of WrapGrip in ItemPanelTemplate