Metro应用程序中的GridView滚动不起作用

时间:2012-07-02 08:27:08

标签: xaml gridview windows-8 microsoft-metro windows-runtime

我尝试构建一个使用GridView的winRT metro应用程序。我得到GridView,它看起来像我想要它做。但水平滚动不起作用。当我拖动它移动的内容但是当我释放它时,它将返回开始。

任何知道它为什么不起作用的人?

<Page
    x:Class="WR.Levels"
    IsTabStop="false"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Wordy"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:uc="using:Wordy.UserControls"
    mc:Ignorable="d">
    <UserControl.Resources>
        <CollectionViewSource x:Name="cvsLevels" IsSourceGrouped="True"/>

        <CollectionViewSource x:Name="cvsCategories" IsSourceGrouped="True" ItemsPath="Levels"/>

    </UserControl.Resources>
<Canvas x:Name="innertialCanvas" 
                Grid.Row="1"
                Background="#FF3D6E4F" 
  >
<uc:BG HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />  

<Grid>

            <Grid.RowDefinitions>
                <RowDefinition Height="84"/>
                <RowDefinition Height="700"/>
            </Grid.RowDefinitions>

            <StackPanel Margin="20,20,0,0" Grid.Row="0" Orientation="Horizontal">
                <Button x:Name="backButton" Style="{StaticResource BackButtonStyle}"   Margin="10" VerticalAlignment="Center"  >Back</Button>

                <TextBlock Name="appName" Text="WR" FontSize="48" VerticalAlignment="Center" />
            </StackPanel>
<GridView ItemsSource="{Binding Source={StaticResource cvsCategories}}" Margin="0,0,0,0" 
          IsItemClickEnabled="True" SelectionMode="None" MaxHeight="700" Grid.Row="1"
          AutomationProperties.AutomationId="LevelsGrid">
                <GridView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Width="150" Height="130" Margin="10" AutomationProperties.AutomationId="Level">
                            <StackPanel.Background>
                                <SolidColorBrush Color="White" Opacity="0.2" />
                            </StackPanel.Background>
                            <StackPanel Orientation="Horizontal" Margin="10">
                                <uc:Stars Height="50" Width="50" />
                                <uc:Stars Height="50" Width="50" />

                            </StackPanel>
                            <TextBlock Text="{Binding Name}" Margin="0,10,0,0" FontSize="24" HorizontalAlignment="Center"></TextBlock>
                        </StackPanel>
                    </DataTemplate>
                </GridView.ItemTemplate>
                <GridView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <VirtualizingStackPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </GridView.ItemsPanel>


        <GridView.GroupStyle>
                <GroupStyle HidesIfEmpty="True">
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <Grid Margin="0">
                                <TextBlock Text='{Binding Name}' 
                                   Foreground="White" Margin="20"
                                   Style="{StaticResource HeaderTextStyle}" AutomationProperties.AutomationId="LevelGroup"/>
                            </Grid>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>

                    <GroupStyle.ContainerStyle>
                        <Style TargetType="GroupItem">

                        <Setter Property="Margin" Value="3,0"/>
                        </Style>
                    </GroupStyle.ContainerStyle>

                    <GroupStyle.Panel>
                        <ItemsPanelTemplate>
                            <VariableSizedWrapGrid/>
                        </ItemsPanelTemplate>
                    </GroupStyle.Panel>
                </GroupStyle>
            </GridView.GroupStyle>

            </GridView>
        </Grid>
    </Canvas>
</Page>

1 个答案:

答案 0 :(得分:1)

当我删除canvas标签时,它有效!