经过多次尝试运行此功能后,我终于完全迷失了。仅显示组标题并且仅在 ZoomInView 中显示。我哪里错了?我所有的数据都是从 web api 服务加载的,但我认为 CollectionViewSource 是可观察的,这不会是问题的根源。
这些是我的 poco 课程
public class StopInformation
{
public string Name { get; set; }
public string Number { get; set; }
}
public class ScheduleDirection
{
public string Direction { get; set; }
public IEnumerable<StopInformation> Stops { get; set; }
}
视图模型成员
public ObservableCollection<ScheduleDirection> Directions { get; set; }
在我的页面 xaml 资源中
<CollectionViewSource x:Name="cvs" IsSourceGrouped="true"
Source="{Binding Directions}" />
以及语义缩放代码:
<SemanticZoom x:Name="semanticZoom">
<SemanticZoom.ZoomedOutView>
<GridView ItemsSource="{Binding Path=View.CollectionGroups, Source={StaticResource cvs}}" ScrollViewer.IsHorizontalScrollChainingEnabled="False">
<GridView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Direction}"/>
</DataTemplate>
</GridView.ItemTemplate>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
</SemanticZoom.ZoomedOutView>
<SemanticZoom.ZoomedInView>
<GridView ItemsSource="{Binding Source={StaticResource cvs}}" IsSwipeEnabled="True" ScrollViewer.IsHorizontalScrollChainingEnabled="False">
<GridView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</GridView.ItemTemplate>
<GridView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock Text='{Binding Direction}' />
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.ContainerStyle>
<Style TargetType="GroupItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="GroupItem">
<StackPanel Orientation="Vertical">
<ContentPresenter Content="{TemplateBinding Content}" />
<ItemsControl x:Name="ItemsControl" ItemsSource="{Binding Stops}" />
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</GridView.GroupStyle>
<Button Visibility="Collapsed"/>
</GridView>
</SemanticZoom.ZoomedInView>
</SemanticZoom>
接受任何想法。