【问题标题】:Semantic Zoom shows no results语义缩放显示没有结果
【发布时间】:2013-10-02 09:43:31
【问题描述】:

在多次尝试运行此功能后,我最终完全迷失了方向。 仅显示组标题并且仅在 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>

接受任何想法。

【问题讨论】:

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


    【解决方案1】:

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

    CollectionViewSource 上使用ItemsPath 属性。在msdn 上阅读更多相关信息。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-17
      • 2019-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-03
      相关资源
      最近更新 更多