c# - 为什么当我切换语义缩放时,它没有导航到该部分?

标签 c# xaml windows-8 microsoft-metro semantic-zoom

我的语义缩放有些奇怪。我有两个部分:

enter image description here enter image description here

当我设置 ZoomOut 时,分组没问题,这是图像:

enter image description here

但是例如,如果我选择第二个选项,语义缩放不会将我导航到单击的项目。

这是我的程序中最重要的部分。

    <!-- from resources -->
    <CollectionViewSource
        x:Name="groupedItemsViewSource"
        Source="{Binding Groups}"
        IsSourceGrouped="False">

    ...

    <!-- Horizontal scrolling grid used in most view states -->
    <SemanticZoom x:Name="semanticZoomControl" Grid.Row="1" >
        <SemanticZoom.ZoomedInView>
            <ListView x:Name="itemGridView" SelectionMode="None" IsItemClickEnabled="False"
                      ScrollViewer.VerticalScrollBarVisibility="Disabled"
                      ScrollViewer.VerticalScrollMode="Disabled"
                      ScrollViewer.HorizontalScrollBarVisibility="Auto"
                      ScrollViewer.HorizontalScrollMode="Auto"
                      Margin="0,-3,0,0"
                      Padding="116,0,40,46"
                      ItemTemplateSelector="{StaticResource StartItemSelector}"
                      ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
                      ItemContainerStyle="{StaticResource ListViewItemStyleFlat}">
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal" />
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>
            </ListView>
        </SemanticZoom.ZoomedInView>
        <SemanticZoom.ZoomedOutView>
            <ListView x:Name="groupGridView" CanDragItems="False"
                      CanReorderItems="False" SelectionMode="None" IsItemClickEnabled="True"
                      ScrollViewer.HorizontalScrollBarVisibility="Auto"
                      ScrollViewer.HorizontalScrollMode="Auto"
                      ScrollViewer.VerticalScrollBarVisibility="Disabled"
                      ScrollViewer.VerticalScrollMode="Disabled"
                      ItemContainerStyle="{StaticResource ListViewItemStyleSimple}"
                      ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
                      ItemTemplateSelector="{StaticResource ZoomedOutSelector}">
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"  Height="330"
                                    HorizontalAlignment="Left" VerticalAlignment="Top" />
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>
            </ListView>

发生这种情况的原因可能是什么?

如果你觉得更舒服,你可以从网盘下载工程:http://sdrv.ms/Ma0LmE

最佳答案

您需要像这样在代码隐藏中设置 Zoomed Out GridView 的 ItemsSource

groupGridView.ItemsSource = groupedItemsViewSource.View.CollectionGroups;

您很可能需要更新该网格的模板,以附加“组”。在你的绑定(bind)之前。

您的 ItemTemplateSelector 也将停止工作,因为它将传递一个 DependencyObject 而不是您的绑定(bind)组。您可以将对象转换为 ICollectionViewGroup,它具有可以转换为模型对象等的 Group 属性。

这一切都很痛苦,但我目前找不到更好的方法。

关于c# - 为什么当我切换语义缩放时,它没有导航到该部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11673521/

相关文章:

c# - RichTextBlock 段落背景颜色

c# - 与 Entity Framework 的松散耦合

c# - 在没有窗口的 WPF 应用程序中处理命令

c# - 如何在 Win8 C# 应用程序中设置专辑插图?

c# - 如何在 DataGrid 中隐藏自动生成的列?

xaml - 如何在 (Uno 2.4) 中使用 Microsoft.UI.Xaml.Controls 资源

windows-8 - 如何用两个拇指实现自定义 slider ?

c# - 如果没有订阅者在一个月内不检索消息,如何自动删除 Azure 服务总线中的队列?

c# - Controller 中的 Asp .Net 方法采用字符串列表

c# - 多 View 刷新页面并丢失 ASP.NET Webform 中的数据