我有一个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上的音乐应用程序中一样,标题为“正在播放&gt;”或“最受欢迎的&gt;”放置在GridView的上方。怎么做?
答案 0 :(得分: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标头:
<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>
答案 1 :(得分: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设置所需的任何属性
答案 2 :(得分: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
答案 3 :(得分:0)
&lt; - 试试这个 - &gt;
<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>