如何使GridView的标题具有columnspan?

时间:2012-12-23 18:19:26

标签: xaml gridview windows-8

我有以下内容,其中白色矩形是GridViewItems,“Abilities”是标题。

White rectangles are GridViewItems and 'Abilities' is the Header

如何使标题位于所有列的上方?

简称我的代码:

<GridView Header="Abilities" Margin="0" SelectionMode="None" >
<GridViewItem></GridViewItem>
<GridViewItem></GridViewItem>
<GridViewItem></GridViewItem>
<GridViewItem></GridViewItem>
<GridViewItem></GridViewItem>
</GridView>

2 个答案:

答案 0 :(得分:1)

两种选择:

<GridView HorizontalAlignment="Left" Width="400" Height="400" Header="Abilities">
    <GridView.ItemsPanel>
        <ItemsPanelTemplate>
            <VariableSizedWrapGrid Orientation="Horizontal" Width="400" />
        </ItemsPanelTemplate>
    </GridView.ItemsPanel>
    <GridViewItem/>
    <GridViewItem />
    <GridViewItem/>
    <GridViewItem />
    <GridViewItem />
    <GridViewItem />
</GridView>

或者

<Grid Width="400" Height="300">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <TextBlock Style="{StaticResource SubheaderTextStyle}" Text="Abilities" Margin="0 20" />
    <GridView Grid.Row="1">
        <GridViewItem />
        <GridViewItem />
        <GridViewItem />
    </GridView>
</Grid>

答案 1 :(得分:-1)

尝试将标题放在GridView

之外
<TextBlock Text="Abilities"/>

<GridView Margin ="0" SelectionMode="None" />
    <GridViewItem></GridViewItem>
    <GridViewItem></GridViewItem>
    <GridViewItem></GridViewItem>
    <GridViewItem></GridViewItem>
    <GridViewItem></GridViewItem>
</GridView>