2

我试图构建一个使用 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>
4

1 回答 1

1

当我删除画布标签时,它起作用了!

于 2012-07-02T12:05:48.943 回答