我有一个Grid
,其中我定位了许多元素。其中一个是Label
,它距离网格顶部30像素。
当用户调整Grid
时,Label
保持距离顶部30像素,这就是我想要的......直到Grid
的高度小于30 +标签高度并且Label
开始消失在网格的底部。
我希望Label
与顶部保持30像素(除外),当边距和Label
没有足够的空间时,我希望边距为缩小并允许Label
尽可能长时间保持在视野中。
我尝试了RowDefinitions
的各种排列但没有成功。可以吗?
答案 0 :(得分:2)
如果布局没有太多杂乱,你可以做这样的事情:
<Grid>
<Grid.RowDefinitions>
<RowDefinition MaxHeight="30"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Grid.Row="1" HorizontalAlignment="Center" Content="Lorem Ipsum"/>
</Grid>