2016-02-25 150 views
2

我在C#(WPF)中編程。我用網格如下4行:設計網格wpf

<Grid> 
    <Grid.RowDefinitions> 
     <RowDefinition> 
     <RowDefinition> 
     <RowDefinition> 
     <RowDefinition> 
    </Grid.RowDefinitions> 

    <!-- Height of this row is related to its content --> 
    <Grid Row="0"> 
    </Grid> 

    <!-- Height of this row is related to its content --> 
    <Grid Row="1"> 
    </Grid> 

    <!-- Remaining of Height should be used here... --> 
    <Grid Row="2"> 
    </Grid> 

    <!-- Height of this row is related to its content and this row should be stick to bottom of page --> 
    <Grid Row="3"> 
    </Grid> 

</Grid> 

根據我的XAML代碼註釋:

    在行= 0
  • ,身高有關,其內容在行= 1
  • ,身高與它的內容行= 3
  • ,身高有關,其內容和該行應堅持
  • 頁行= 2
  • 的底部,剩餘的身高應該在這裏使用

如何根據四個命名條件調整我的行定義?

更多的想象看到這樣的畫面: enter image description here

回答

2

我無法在Windows所以我現在不能測試,但我會嘗試這樣的事情。

在你RowDefinition:

<RowDefinition Height="Auto"/> 
<RowDefinition Height="Auto"/> 
<RowDefinition Height="*"/> 
<RowDefinition Height="Auto"/> 

高度=「自動」,這意味着該行將採取僅由其內容需要儘可能多的高度。

Height =「*」,表示該行將取所有可用的剩餘高度。

+1

This works。具有'*'高度的第三行將確保第四行始終被推到頁面的底部。 – Stewbob