gpt4 book ai didi

wpf - 如何使 GridView 将其内容包装在 XAML 中?

转载 作者:行者123 更新时间:2023-12-02 04:41:01 26 4
gpt4 key购买 nike

作为帖子的标题,我想制作一个可以将所有内容包裹在其中的 GridView,这意味着如果我有 3 个项目,每个项目都有 50px 的高度,那么如何制作一个 GridView 包含这些项目的 50 *3=150px 的高度。
怎么办,求大神帮帮忙!

P/s:我想通过配置 XAML 代码来实现,而不是在 C# 代码中,谢谢!

最佳答案

我找到了答案!只需将 GridView 的高度设置为 Auto,将其置于 Grid 行内。

                <Grid Grid.Row="0"
Margin="12,24">
<Grid.RowDefinitions>
<RowDefinition Height="64" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Opacity=".8"
Background="White"
Height="64">
<Grid Margin="8">
<TextBlock Text="Students"
VerticalAlignment="Center"
FontSize="24" />
</Grid>
<Grid Height="2"
VerticalAlignment="Bottom"
Background="#B0BEC5" />
</Grid>

<GridView Background="White"
Name="grvMatchGA"
Grid.Row="1"
ItemTemplate="{ThemeResource groupItemTemplate}"
Opacity=".8"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
VerticalAlignment="Stretch">
</GridView>
</Grid>

关于wpf - 如何使 GridView 将其内容包装在 XAML 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37583072/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com