开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜