1

我有一个 GridView:

<GridView HorizontalAlignment="Left" Width="400" Height="400" Header="AAAAAA">
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
        </GridView>

在此处输入图像描述

我只是想要 GridView 上侧的 AAAAA,而不是它干预 GridViewItem 位置的左侧。你知道,就像在 Windows 8 上的音乐应用程序中一样,标题“正在播放>”或“最流行的>”放置在 GridView 的上侧。怎么做?

4

4 回答 4

1

尝试这个:

    <GridView HorizontalAlignment="Left" Width="400" Height="400" Header="AAAAA">
        <GridView.ItemsPanel>
            <ItemsPanelTemplate>
                <VariableSizedWrapGrid Orientation="Horizontal" Width="400" />
            </ItemsPanelTemplate>
        </GridView.ItemsPanel>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
    </GridView>

或者,您可以执行以下操作,而不是使用 GridView 的 Header:

    <Grid Width="400" Height="300">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <TextBlock Style="{StaticResource SubheaderTextStyle}" Text="My Header" Margin="0 20" />
        <GridView Grid.Row="1">
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
            <GridViewItem Content="GridViewItem" Margin="0"/>
        </GridView>
    </Grid>
于 2012-12-02T13:25:05.300 回答
0

尝试这个:

<GridView HorizontalAlignment="Left" Width="400" Height="400">
        <GridView.Header> <TextBlock Text="AAAAA" Margin="240,0,0,0"/>
        </GridView.Header>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
    </GridView>

您可以为 TextBlock 设置所需的任何属性

于 2012-12-02T12:59:36.987 回答
0
<GridView HorizontalAlignment="Left" Width="400" Height="400" Header="AAAAA">
        <GridView.ItemsPanel>
            <ItemsPanelTemplate>
                <VariableSizedWrapGrid Orientation="Horizontal" Margin="-80,20,0,0" Width="400" />
            </ItemsPanelTemplate>
        </GridView.ItemsPanel>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
        <GridViewItem Content="GridViewItem" Margin="0"/>
    </GridView>

Or you can adjust the margin of the variableSizedWrapGrid, so that the alignment of the header and Items should appear in same line
于 2013-10-23T11:35:06.290 回答
0

<--试试这个-->

<GridView HorizontalAlignment="Left" Width="400" Grid.Row="1" Height="400">
<GridView.Header>
<TextBlock Text="AAAAA" />
</GridView.Header>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid Margin="-35,20,0,0"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
<GridViewItem Content="GridViewItem" Margin="0"/>
</GridView>
于 2013-10-29T12:54:23.950 回答