Xaml wp8.1运行时:如何使gridview项先向右流动,然后向下流动?

Xaml wp8.1运行时:如何使gridview项先向右流动,然后向下流动?,xaml,gridview,windows-phone,windows-phone-8.1,Xaml,Gridview,Windows Phone,Windows Phone 8.1,在默认集线器模板中,gridview项首先位于底部,然后位于右侧。 例如: 1 3 5 7 2 4 6 8 但是通过这种方式,如果有很多图像,那么中心的滚动就会变得很长,并且需要花费太多的时间才能到达第2节。 如何让它们这样漂浮 1 2 3 4 5 6 7 8 我认为这部分必须编辑,但我不知道如何: <GridView ... ...> <GridView.ItemsPanel> <ItemsPanelTemplat

在默认集线器模板中,gridview项首先位于底部,然后位于右侧。 例如:

1 3 5 7
2 4 6 8
但是通过这种方式,如果有很多图像,那么中心的滚动就会变得很长,并且需要花费太多的时间才能到达第2节。 如何让它们这样漂浮

1 2 
3 4
5 6
7 8
我认为这部分必须编辑,但我不知道如何:

<GridView ...
          ...>
    <GridView.ItemsPanel>
        <ItemsPanelTemplate>
            <ItemsWrapGrid />
        </ItemsPanelTemplate>
    </GridView.ItemsPanel>
</Gridview>

只需将其全部删除即可。GridView的默认行为是穿过然后向下:

<StackPanel Width="350" Height="300" Background="AliceBlue">
  <GridView Background="BurlyWood" x:Name="MyGridView"/>
</StackPanel>

 protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        List<string> MyList = new List<string>();
        MyList.Add("1");
        MyList.Add("2");
        MyList.Add("3");
        MyList.Add("4");
        MyList.Add("5");
        MyList.Add("6");
        MyList.Add("7");
        MyList.Add("8");
        MyList.Add("9");
        MyList.Add("10");
        MyList.Add("11");
        MyList.Add("12");
        MyList.Add("13");
        MyList.Add("14");
        MyList.Add("15");
        MyList.Add("16");
        MyGridView.ItemsSource = MyList;
    }

受保护的覆盖无效OnNavigatedTo(NavigationEventArgs e)
{
List MyList=新列表();
MyList.添加(“1”);
MyList.添加(“2”);
MyList.添加(“3”);
MyList.添加(“4”);
MyList.添加(“5”);
MyList.添加(“6”);
MyList.添加(“7”);
MyList.添加(“8”);
MyList.添加(“9”);
MyList.添加(“10”);
MyList.添加(“11”);
MyList.添加(“12”);
MyList.添加(“13”);
MyList.添加(“14”);
MyList.添加(“15”);
MyList.添加(“16”);
MyGridView.ItemsSource=MyList;
}


然后您只需设置父项(在本例中为StackPanel)将
更改为
,或者可能需要将最大值替换为MaxWidth,以设置调用WrapWhy trade one Panel for two的边界。当您可以在他使用的面板上设置方向时,为什么要将一个面板换成两个?默认值是垂直的,我在写了这篇文章后就想到了,但不管怎样,它都是有效的。