Xaml 如何使用RelativePanel指定以下布局?
我尝试了一些不同的Xaml 如何使用RelativePanel指定以下布局?,xaml,Xaml,我尝试了一些不同的RelativePanel.Align…附加属性组合,但我似乎无法按照我想要的方式解决问题 +--+---+--+ | |RED| | +------+ | | BLUE | | +------+--+ 如果我处在你的位置,我会使用网格 <!-- this version overlays Red beneath Blue, but aligned on the right --> <Rectangle x:Name="Red" RelativePa
RelativePanel.Align…
附加属性组合,但我似乎无法按照我想要的方式解决问题
+--+---+--+
| |RED| |
+------+ |
| BLUE | |
+------+--+
如果我处在你的位置,我会使用
网格
<!-- this version overlays Red beneath Blue, but aligned on the right -->
<Rectangle x:Name="Red" RelativePanel.AlignRightWith="Blue" />
<Rectangle x:Name="Blue" />
<!-- this version shoves Blue half off-screen -->
<Rectangle x:Name="Red" />
<Rectangle x:Name="Blue" RelativePanel.AlignRightWith="Red" RelativePanel.Below="Red" />
<!-- this version is a circular dependency -->
<Rectangle x:Name="Red" RelativePanel.AlignRightWith="Blue" />
<Rectangle x:Name="Blue" RelativePanel.Below="Red" />
是的,使用网格很容易,但我只是在尝试新的UAP控件,想看看RelativePanel
有什么可能。据我所知,RelativePanel
是一个不错的选择,但在某些情况下,您仍然需要依赖基于显式网格的布局。FWIW,我很确定第三个选项在同等的Android布局中不会是循环依赖性错误,所以如果微软有人注意到这个问题就好了。:)
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Rectangle Fill="Red" Grid.Column="1" ... />
<Rectangle Fill="Blue" Grid.Row="1" Grid.ColumnSpan="2" ... />
</Grid>