Windows Phone 8.1中的ItemsWrapGrid顺序

时间:2015-06-12 21:02:45

标签: c# xaml listview windows-phone-8.1

我在XAML中设置了以下示例数据:

<vm:SoundModel.Animals>
  <vm:SoundGroup Title="Animals">
    <vm:SoundGroup.Items>
      <vm:SoundData Title="Animal 1" FilePath="Animal1.wav" />
      <vm:SoundData Title="Animal 2" FilePath="Animal2.wav" />
      <vm:SoundData Title="Animal 3" FilePath="Animal3.wav" />
    </vm:SoundGroup.Items>
  </vm:SoundGroup>
</vm:SoundModel.Animals>

在我的XAML中,我有以下内容:

<Page.Resources>
  <DataTemplate x:Key="SoundTileDataTemplate">
    <Grid Background="{StaticResource PhoneAccentBrush}" Margin="0, 0, 20, 20">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="170" />
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
        <RowDefinition Height="150" />
      </Grid.RowDefinitions>

      <Grid VerticalAlignment="Top" HorizontalAlignment="Right" Width="40" Height="40" Margin="0, 10, 10, 0">
        <Ellipse Stroke="{StaticResource PhoneForegroundBrush}" StrokeThickness="3" />
        <Image Source="Assets/AppBar/play.png" />
      </Grid>

      <StackPanel VerticalAlignment="Bottom" Margin="6, 0, 0, 6">
        <TextBlock Text="{Binding Title}" FontSize="30"  />
      </StackPanel>
    </Grid>
  </DataTemplate>
</Page.Resources>

<Pivot x:Uid="Pvt">
  <PivotItem Header="{Binding Animals.Title}">
    <ListView ItemsSource="{Binding Animals.Items}" ItemTemplate="{StaticResource SoundTileDataTemplate}">
      <ListView.ItemsPanel>
        <ItemsPanelTemplate>
          <ItemsWrapGrid MaximumRowsOrColumns="2"  Orientation="Vertical"></ItemsWrapGrid>
        </ItemsPanelTemplate>
      </ListView.ItemsPanel>
    </ListView>
  </PivotItem>
</Pivot>

上面给出了以下内容:

listview boxes

我必须更改哪些代码才能从左向右流动?所以Animal 3应该在底部。我已经尝试设置Orientation="Horizontal"给我这个:

orientation different

由于

1 个答案:

答案 0 :(得分:1)

您想要更改方向。

<ItemsWrapGrid MaximumRowsOrColumns="2"  Orientation="Horizontal"></ItemsWrapGrid>

ItemsWrapGrid.Orientation property