Xaml 当另一个元素部分遮挡它时,包装VariableSizedWrapGrid
我有以下XAML代码Xaml 当另一个元素部分遮挡它时,包装VariableSizedWrapGrid,xaml,uwp,Xaml,Uwp,我有以下XAML代码 <RelativePanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <VariableSizedWrapGrid Orientation="Horizontal"> <Rectangle Width="400" Height="400" Fill="Green"/> <Rectangle Width=
<RelativePanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<VariableSizedWrapGrid Orientation="Horizontal">
<Rectangle Width="400" Height="400" Fill="Green"/>
<Rectangle Width="400" Height="400" Fill="Blue"/>
</VariableSizedWrapGrid>
<Rectangle Width="600" MinWidth="600" Height="600" Fill="Pink" RelativePanel.AlignRightWithPanel="True"/>
</RelativePanel>
代码生成以下页面
当应用程序窗口的宽度变暗时,应用程序窗口如下所示
当粉色方块部分遮住蓝色方块时,我如何使蓝色方块包裹(在绿色方块下方)
当我使用社区工具包的WrapPanel而不是VariableSizedWrapGrid时,也会发生完全相同的情况。下面的代码显示了它的外观
<RelativePanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Rectangle Width="600" MinWidth="600" Height="600" Fill="Pink" RelativePanel.AlignRightWithPanel="True"/>
<wrapPanel:WrapPanel Orientation="Horizontal" >
<Rectangle Width="400" Height="400" Fill="Green"/>
<Rectangle Width="400" Height="400" Fill="Blue"/>
</wrapPanel:WrapPanel>
</RelativePanel>
开始调整页面大小时,
WrapPanel
的宽度根本没有改变,这就是为什么您看不到绿色矩形以转到第二行的原因
诀窍是给WrapPanel
一个与粉红色边框宽度相等的右边框
<wrapPanel:WrapPanel Orientation="Horizontal" Margin="0,0,600,0">
你是说当你使用WrapPanel
并调整应用程序窗口大小时,里面的控件不会回流到正确的位置?@JustinXL。我添加了显示如何使用WrapPanel的代码。注意,我只将VariableSizedWrapGrid交换为WrapPanel。没有进行其他更改。对WrapPanel的任何其他更改可能会产生影响吗?