开发者

Resizing window content gets clipped

I need help with this code:

<Grid HorizontalAlignment="Center" >
            <Grid.RowDefinitions>
                <RowDefinition Height="1*"/>
                <RowDefinition Height="1*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Label Grid.Row="0" Grid.Column="0" Background="Black" Width="{Binding RelativeSource={RelativeSource Self}, Path=ActualHeight}"></La开发者_如何学运维bel>
            <Label Grid.Row="1" Grid.Column="0" Background="Gray" Width="{Binding RelativeSource={RelativeSource Self}, Path=ActualHeight}"></Label>
            <Label Grid.Row="0" Grid.Column="1" Background="Gray" Width="{Binding RelativeSource={RelativeSource Self}, Path=ActualHeight}"></Label>
            <Label Grid.Row="1" Grid.Column="1" Background="Black" Width="{Binding RelativeSource={RelativeSource Self}, Path=ActualHeight}"></Label>
        </Grid>

The problem is, when the window's height is larger than it's width, the grid inside the window gets clipped. Can someone help me please?


What happens if you put the grid in a scroll viewer?

If the case is you don't want to use a scroll viewer could you bind the Grids MaxWidth and MaxHeight to the Windows Width and Height?


To avoid clipping content when resizing the window, use a viewBox. Thank's to H.B. for pointing this out! Here's the link to the original post I made : How to keep grid cell height and width the same

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜