语义缩放显示没有结果

时间:2013-10-02 09:43:31

标签: xaml gridview windows-8 winrt-xaml semantic-zoom

经过多次尝试运行此功能后,我绝对迷失了方向。 仅显示组标题,仅在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; }
}

ViewModel会员

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>

接受任何想法。

1 个答案:

答案 0 :(得分:0)

我自己遇到了这个问题并经过一些搜索后找到了解决方案。对于OP来说可能为时已晚,但我会为了其他可能遇到同样问题的人发布它。

使用ItemsPath上的CollectionViewSource属性。请在msdn上了解详情。

 <CollectionViewSource 
      x:Name="cvs" 
      IsSourceGrouped="true"
      Source="{Binding Directions}" 
      ItemsPath="Stops" />                    <!-- Add this last bit -->
相关问题