C# Gridview内容拉伸UWP
在xaml中,是否可以使GridView的内容拉伸,以便在更改GridView的宽度时,这些项可以处理拉伸?我尝试使用HorizontalContentAlignment,但它不起作用 MainPage.xaml:C# Gridview内容拉伸UWP,c#,xaml,uwp,C#,Xaml,Uwp,在xaml中,是否可以使GridView的内容拉伸,以便在更改GridView的宽度时,这些项可以处理拉伸?我尝试使用HorizontalContentAlignment,但它不起作用 MainPage.xaml: <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <GridView x:Name="GridViewItemList" HorizontalContentAli
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<GridView x:Name="GridViewItemList" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch" ItemContainerTransitions="{x:Null}" Margin="0,50,0,0" SizeChanged="GridViewItemList_SizeChanged">
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridViewItem Content="Item" Width="100" Height="100" HorizontalContentAlignment="Center" Background="#FF2D7496" Foreground="White" FontSize="36"/>
<GridView.Style>
<Style TargetType="GridView">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Margin" Value="5"/>
</Style>
</GridView.Style>
</GridView>
</Grid>
我希望,随着GridView宽度的变化,项目分布在GridView的整个宽度上
谢谢您的帮助。您应该查看的是。此控件在这方面非常智能,可以根据需要自动拉伸控件,以使行均匀填充,并且两侧都没有剩余空间。是否希望固定大小的项目填充gridview中的可用空间?