2010-03-31 10 views
2

나는 3 개월 동안 WPF 작업을 한 후 나는이 다시 해요 믿을 수 없어 내용의 높이와 가운데 행 (주 내용)에 맞게 하단 행 (메뉴 막대 및 상태 표시 줄) 크기가 프로그램에서 남아있는 사용 가능한 공간을 채 웁니 까?간단한 그리드 레이아웃 질문

내용의 높이가 다를 수 있으므로 상단/하단 행의 높이를 고정 할 수 없습니다.

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

    <Menu Grid.Row=0> 
    ...menuitems 
    </Menu> 

     <Grid Grid.Row=1> 
     ...main application content here (like most programs) 
     </Grid> 

     <StatusBar> 
     ...statusbaritems 
     </StatusBar> 
    </Grid> 
</Window> 

답변

4
<Grid.RowDefinitions> 
    <RowDefinition Height="Auto" /> 
    <RowDefinition Height="*" /> 
    <RowDefinition Height="Auto" /> 
</Grid.RowDefinitions> 

:

자동 : 크기는 내용의 크기 속성에 의해 결정된다 목적.
별표 : 값은 사용 가능한 공간의 가중치 비율로 표시됩니다.

+0

감사! 상태 표시 줄의 이미지가 "숨김"으로 설정되어 있고 사용 가능한 영역을 채우는 것이 기본값입니다. 그게 내 최하위 행이 화면의 90 %를 차지하는 이유입니다! :) 일단 내가 그것을 해결하면, 당신의 솔루션은 완벽하게 작동합니다. –

3

당신은 사용

<Grid.RowDefinitions> 
    <RowDefinition Height="Auto" /> 
    <RowDefinition Height="*" /> 
    <RowDefinition Height="Auto" /> 
</Grid.RowDefinitions> 

자동 크기 내용, 그리고 * 공간을 채울 것입니다. 당신이 사이에 다수의 "내용"영역이 있다면, 당신도, 배수를 사용할 수 있습니다 GridUnitType Enumeration에서

<Grid.RowDefinitions> 
    <RowDefinition Height="Auto" /> 
    <RowDefinition Height="2*" /> <!-- Will be 2/3rd of main space --> 
    <RowDefinition Height="1*" /> <!-- Will be 1/3rd of main space --> 
    <RowDefinition Height="Auto" /> 
</Grid.RowDefinitions>