c# - 与具有多行的网格相比,用于 XAML 的控制更好
问题描述
如果您想组织一个包含许多行的网格的 XAML 页面,并且发现自己在开发过程中经常需要对页面进行调整,这似乎有点低效。例如,需要在插入后将每个控件的属性从 row="40" 更改为 row="41" ,依此类推,在顶部插入后向下一行。网格似乎是我发现的用于控制布局的最佳控件,但还有其他控件。在这种多行多列的情况下,最好使用什么控件?
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
解决方案
StackPanel 是只有Auto
行的 Grid 的完美替代品:
<StackPanel>
<TextBlock Text="Row 1"/>
...
<TextBlock Text="Row N"/>
<StackPanel>
如果 Grid 中只有带有 的行Height="*"
,它将是 UniformGrid:
<UniformGrid Columns="1">
<TextBlock Text="Row 1"/>
...
<TextBlock Text="Row N"/>
</UniformGrid>
推荐阅读
- amazon-web-services - 检查我是否以 IAM 用户身份登录
- spark-structured-streaming - 无法读取使用分区的 spark 结构化流创建的分区配置单元表
- python-3.x - ansible aws_s3 错误:botocore.exceptions.ClientError:调用 HeadBucket 操作时发生错误(400):错误请求
- php - PHP Post变量未显示
- json - 如何在 json 结果中分隔逗号(React Js)
- java - 检查java中的条件导致错误
- reactjs - 使用 axios 获取图像并将其用作背景图像
- tensorflow - 如何获得可重现的结果(Keras、Tensorflow):
- python - 多索引 Pandas 数据框并在 excel 中导出
- spring-boot - 将参数传递给 IntelliJ IDEA 中的 Liquibase Gradle 插件配置