1

Windows 8 アプリケーションで SemanticZoom を使用しようとしていますが、動作しないようです。

ここで何か間違っていますか?うまくいくと思ったほとんどすべてを試しましたが、無駄でした:行定義を削除し、スタイルを削除し、テンプレートを削除しましたが、まだ機能していません...

<Grid Style="{StaticResource LayoutRootStyle}">
    <Grid.RowDefinitions>
        <RowDefinition Height="140"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <SemanticZoom Grid.RowSpan="2">            
        <SemanticZoom.ZoomedInView>
             <GridView x:Name="itemGridView"
                      AutomationProperties.AutomationId="ItemGridView"
                      AutomationProperties.Name="Grouped Items"
                      Padding="116,137,40,46"
                      ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
                      SelectionMode="None"
                      IsSwipeEnabled="True"
                      IsItemClickEnabled="True"
                      ItemTemplate="{StaticResource GridViewItemTemplateZoomIn}"
                      ItemsPanel="{StaticResource GridViewItemsPanelTemplate}"
                      helpers:ItemClickCommand.Command="{Binding ServiceClickCommand}">
                <GridView.GroupStyle>
                    <GroupStyle HidesIfEmpty="True">
                        <GroupStyle.HeaderTemplate>
                            <DataTemplate>
                                <Grid Margin="1,0,10,6">
                                    <Button AutomationProperties.Name="Group Title"
                                            Style="{StaticResource TextPrimaryButtonStyle}">
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding Name}"
                                                       Margin="3,-7,10,10"
                                                       Style="{StaticResource GroupHeaderTextStyle}" />
                                            <TextBlock Text="{StaticResource ChevronGlyph}"
                                                       FontFamily="Segoe UI Symbol"
                                                       Margin="0,-7,0,10"
                                                       Style="{StaticResource GroupHeaderTextStyle}" />
                                        </StackPanel>
                                    </Button>
                                </Grid>
                            </DataTemplate>
                        </GroupStyle.HeaderTemplate>
                        <GroupStyle.Panel>
                            <ItemsPanelTemplate>
                                <VariableSizedWrapGrid Orientation="Vertical"
                                                       Margin="0,0,80,0" />
                            </ItemsPanelTemplate>
                        </GroupStyle.Panel>
                    </GroupStyle>
                </GridView.GroupStyle>
            </GridView>
        </SemanticZoom.ZoomedInView>
        <SemanticZoom.ZoomedOutView>
            <GridView x:Name="itemZoomOutGridView"
                      ScrollViewer.IsHorizontalScrollChainingEnabled="False"
                      AutomationProperties.AutomationId="ItemGridView"
                      AutomationProperties.Name="Grouped Items"
                      Padding="116,175,40,46"
                      SelectionMode="None"
                      IsSwipeEnabled="True"
                      IsItemClickEnabled="True"
                      ItemTemplate="{StaticResource GridViewItemTemplateZoomOut}"
                      ItemsPanel="{StaticResource GridViewItemsPanelTemplate}"
                      ItemsSource="{Binding ServiceCategories}">
            </GridView>
        </SemanticZoom.ZoomedOutView>
    </SemanticZoom>

ありがとうございました :)

4

1 に答える 1

0

あなたの問題を正しく理解していれば、セマンティックビュー自体は機能しています (ズームインとズームアウトが可能です)。ただし、GridView アイテムをズームインすると、選択した ZoomedOutView GridView アイテムに応じて同じであり、変更されません。

しかし、XAML では、これは通常の動作だと思います。カテゴリを選択しても、zoomedInView のグリッドビューのバインディングは変更されないためです。

ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"

私の最初のアドバイスは、ItemsSource を ViewModel のリストにバインドし、staticRessource を使用しないことです。

次に、次の方法で SemanticView を変更できます。

<SemanticZoom Grid.RowSpan="2" ViewChangeStarted="SemanticZoomChanged" >

そして、あなたのコードビハインドにそれを追加してください:

private void SemanticZoomChanged(object sender, SemanticZoomViewChangedEventArgs e)
{
   // First we check that we are going from ZoomedOut to ZoomedIn
   if (e.IsSourceZoomedInView == false)
   {
      // I call a method in my ViewModel giving the chosen category in parameter
      DefaultViewModel.OnSelectedCategoryChanged(e.SourceItem.Item.ToString());
   }
}

MVVM を使用すると、コード ビハインドにコードを含めるのは見苦しいことはわかっていますが、これはそれほど多くはなく、ViewModel でメソッドを呼び出してロジックを実行しているため、MVVM の設計パターンに従っています。

最後に、ZoomedInView の ItemsSource を変更する関数を ViewModel に追加します。

OnSelectedCategoryChanged(string chosenCategory)
{
    // Here change the value of your groupedItemsViewSource list
    GroupedItemsViewSource = ....;
}

これで、思いどおりに動作するはずです。

于 2014-10-09T22:08:31.693 に答える