开发者

Margin pushes element out of view when resizing

开发者 https://www.devze.com 2023-04-01 00:50 出处:网络
I have a Grid wherein I have positioned a number of elements. One of them is a Label which is centered 30 pixels from the top of the grid.

I have a Grid wherein I have positioned a number of elements. One of them is a Label which is centered 30 pixels from the top of the grid.

When the user resizes the Grid the Label remains 30 pixels from the top which is what I want... until the height of the Grid becomes less than 30 + label height and the Label begins to disappear at the bottom of the grid.

I would like the Label to stay 30 pixels from the top except when there is not enough space for the margin and the Label, whereupon I want the margin to shrink and allow the Label to remain in view as long as possible.

I have tried 开发者_C百科various permutations of RowDefinitions without success. Can it be done?


You could do something like this if it is not too much of a clutter for the layout:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition MaxHeight="30"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <Label Grid.Row="1" HorizontalAlignment="Center" Content="Lorem Ipsum"/>
</Grid>
0

精彩评论

暂无评论...
验证码 换一张
取 消