GridView项目的高度不同

时间:2015-06-22 16:51:04

标签: user-interface gridview winrt-xaml

我有一个显示标题和子项的GridView,如下所示:

<GridView ItemsSource="{Binding Path=MainViewModels}">
        <GridView.ItemTemplate>
            <DataTemplate>
                <Grid VerticalAlignment="Top">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <Border BorderBrush="White" BorderThickness="1"></Border>
                    <Grid VerticalAlignment="Top" HorizontalAlignment="Left">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Border Grid.Row="0" BorderBrush="White" BorderThickness="1"></Border>
                        <TextBlock Grid.Row="0"
                       HorizontalAlignment="Left"
                       Foreground="#FFAAAAAA"
                       Style="{StaticResource Style_TextBlock_Label_H3}"
                       Text="{Binding Path=Description}" VerticalAlignment="Top" />
                        <GridView Grid.Row="1"
                              ItemsSource="{Binding Path=SubViewModels}">
                            <GridView.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Margin="0,0,5,0"
                                           Text="{Binding Path=Description}"
                                           TextWrapping="Wrap" />
                                </DataTemplate>
                            </GridView.ItemTemplate>
                            <GridView.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <WrapGrid Orientation="Vertical" VerticalAlignment="Stretch" />
                                </ItemsPanelTemplate>
                            </GridView.ItemsPanel>
                        </GridView>
                    </Grid>
                </Grid>
            </DataTemplate>
        </GridView.ItemTemplate>
        <GridView.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal"
                            VerticalAlignment="Top">
                </StackPanel>
            </ItemsPanelTemplate>
        </GridView.ItemsPanel>
    </GridView>

但是,无论何时呈现,它都会呈现如下:enter image description here

我想要实现的是所有&#34; Header&#34;在顶部,而Items本身延伸到底部,然后使用WrapGrid溢出。

请指出我出错的地方?

谢谢!

0 个答案:

没有答案