开发者

WPF layout with several fixed height parts and certain parts relative to window size

开发者 https://www.devze.com 2023-01-04 01:01 出处:网络
At moment my main layout consists of vertically oriented stack panel and it looks like this: Root StackPanel

At moment my main layout consists of vertically oriented stack panel and it looks like this:

Root StackPanel

  • StackPanel - fixed Height 150 (horizontal orientation)

  • StackPanel - relative Height must be behalf of free space left on screen (but at least 150 px). Used by Telerik GridView Control, if I don't specify Height or MaxHeight Telerik GridView Height becomes very large and does not fit my window.

  • StackPanel - fixed Height 100 (horizontal orientation)

  • StackPanel - relative Height must be half of free space left on screen (but at least 150 px). 开发者_如何学CUsed by Telerik GridView Control, if I don't specify Height or MaxHeight Telerik GridView Height becomes very large and does not fit my window.

  • StackPanel - fixed Height 100 (horizontal orientation)

The view must totally fit available screen size.

The problem is that I don't understand how to make certain areas of my view resize depending on available screen size.

Is there is easy way to solve it, or should I be binding to Window height property and doing math?

Thank You very much!


I dont have the telerik controls to hand to test so this is off the top of my head - can you not use a grid as the basis of your control rather than a stackpanel like this? - if this is still a problem then post some code up and we can take a look at what you are trying to achieve.

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="150"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="100"/>
            <RowDefinition Height="*" />
            <RowDefinition Height="100"/>            
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" />
        <StackPanel Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  />
        <StackPanel Grid.Row="2" />
        <StackPanel Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  />
        <StackPanel Grid.Row="4" />
    </Grid>
0

精彩评论

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