uwp-xaml - 如何在 XAML 屏幕中使用 Row 和 RowSpam
问题描述
我将使用
的代码 Row 和 rowspan 正在使用此页面,但我希望行跨度以零索引开始,以 rowspan="3" 结束
<Grid Grid.Row="3" Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Image Source="/Resources//Others/5.png" Margin="2 2 0 0" Stretch="Fill"/>
</Grid>
<Grid Grid.RowSpan="3" Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition Height="65*"/>
<RowDefinition Height="68*"/>
</Grid.RowDefinitions>
<Image Grid.RowSpan="2" Source="/Resources//Others/6.png" Stretch="UniformToFill" Margin="0,2,0,0" HorizontalAlignment="Center" VerticalAlignment="Stretch"/>
</Grid>
<Grid Grid.RowSpan="3" Grid.Column="3">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Image Grid.RowSpan="3" Grid.Column="3" Source="/Resources//Others/6.png" Margin="2 2 0 0" Stretch="UniformToFill" />
</Grid>
</Grid>
像这样的输出屏幕
但我期待这个
解决方案
如何在 XAML 屏幕中使用 Row 和 RowSpam
为了理解这一点,您可以创建 3 列 3 行网格,如下所示。
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
</Grid>
如果您想在整列后面占据两个。你需要设置RowSpan
为 3,然后设置Column
你想要开始。
<Rectangle Fill="LightCyan" Grid.RowSpan="3" Grid.Column="1"/>
<Rectangle Fill="LightGreen" Grid.RowSpan="3" Grid.Column="2"/>
以下是完整的 xaml 代码。
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Rectangle Fill="Red" Grid.Column="0" Grid.Row="0"/>
<Rectangle Fill="Gray" Grid.Column="0" Grid.Row="1"/>
<Rectangle Fill="BlueViolet" Grid.Column="0" Grid.Row="2"/>
<Rectangle Fill="LightCyan" Grid.RowSpan="3" Grid.Column="1"/>
<Rectangle Fill="LightGreen" Grid.RowSpan="3" Grid.Column="2"/>
</Grid>
推荐阅读
- c# - 在 C# 中获取绝对路径
- sql - 如何忽略 SQL Server 中的列
- r - 使用markdown、knitr和glue从data.frame自动生成格式良好的歌词书
- android - 我在哪里可以找到 Google 同意 SDK 的 Consentform.html?
- node.js - 如果用户名和密码已知,则自动获取具有云打印权限的 Google OAuth2 令牌
- python - 无法在 Python 中使用 Selenium 库单击按钮,因为元素是隐藏的(只能使用 JavaScript 这样做)
- r - 在绘图和大小中包含 NA 值,填充图例
- c - 如何正确使用 OpenMP?
- mocha.js - Spectron 测试让窗口打开
- javascript - 通过在量角器测试中发布一些 JSON 数据来调用 Delete rest API