2009-09-27 5 views
9

특정 열 내에서 행을 결합하는 방법이 있습니까? 따라서 (I 현재 제어, 즉 이미지에 ROWSPAN 사용하고 있지만, 더 좋은 방법은 무엇입니까?) 같은 것을 얻기 위해 내가 나에게 같은 것을 제공이 코드 기본적으로WPF : 행 내에서 행을 결합하는 방법 (rowspan 대신)?

<Grid.RowDefinitions> 
     <RowDefinition Height="*" /> 
     <RowDefinition Height="28" /> 
     <RowDefinition Height="28" /> 
     <RowDefinition Height="28" /> 
     <RowDefinition Height="*" /> 
     <RowDefinition Height="28" /> 
    </Grid.RowDefinitions> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="124" /> 
     <ColumnDefinition Width="246*" /> 
    </Grid.ColumnDefinitions> 

을 사용하고

-------------------- 
    |   |--------| 
    |   |--------| 
    |   |--------| 
    |   |--------| 
    |   |--------| 
    -------------------- 

을 이 지금

-------------------- 
    |---------|--------| 
    |---------|--------| 
    |---------|--------| 
    |---------|--------| 
    |---------|--------| 
    -------------------- 

내가 ROWSPAN를 사용할 수있는 이미지를 배치 할 경우 내가 예를 들어이 문제를 얻을 수 있습니다 (행 또한 열 0에 표시주의)하지만 승 열을 설계 할 수 없습니다 수 있습니다 i 행이없고 다른 열은 행이 있습니까?

답변

11

Grid 컨트롤에서는 불가능합니다. 행은 모든 열을 통과하고 열은 모든 행을 통과합니다. 찾은 것처럼 RowSpanColumnSpan을 사용하면 제어 행을 여러 행 또는 여러 개 사용할 수 있습니다.

또 다른 잠재적 인 해결 방법은 또 다른 내에서 하나 Grid를 개최하는 것입니다

<Grid> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="*"/> 
     <ColumnDefinition Width="*"/> 
    </Grid.ColumnDefinitions> 

    <Image/> 

    <Grid Grid.Column="1"> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="*"/> 
      <RowDefinition Height="*"/> 
      <RowDefinition Height="*"/> 
      <RowDefinition Height="*"/> 
      <RowDefinition Height="*"/> 
      <RowDefinition Height="*"/> 
     </Grid.RowDefinitions> 
    </Grid> 
</Grid> 
+0

감사합니다. 켄트 씨가 말씀 드리지만, 추가 코드가 부풀어 오르는 이유는 무엇입니까? .. 나는 그리드를 계속 사용하고 RowSpan 등을 사용하는 것이 더 낫다고 생각 하는가? –

+0

@ Mark : 예, 설명에 따라 판단하면 'RowSpan'이 목표를 달성하는 가장 쉬운 방법이라고 말할 수 있습니다. –

1

어떻게 이런 일에 대해 : 6 개 행을 병합 할 사각형을 사용하는

  <StackPanel Orientation="Horizontal"> 
       <Grid Height="100" Width="50"></Grid> 
       <Grid> 
        <Grid.RowDefinitions> 
         <RowDefinition Height="*" /> 
         <RowDefinition Height="*" /> 
         <RowDefinition Height="*" /> 
         <RowDefinition Height="*" /> 
         <RowDefinition Height="*" /> 
        </Grid.RowDefinitions> 
        <Grid.ColumnDefinitions> 
         <ColumnDefinition Width="150" /> 
        </Grid.ColumnDefinitions> 
       </Grid> 
      </StackPanel> 
0

시도.

<Grid> 
<Grid.RowDefinitions> 
    <RowDefinition Height="*" /> 
    <RowDefinition Height="28" /> 
    <RowDefinition Height="28" /> 
    <RowDefinition Height="28" /> 
    <RowDefinition Height="*" /> 
    <RowDefinition Height="28" /> 
</Grid.RowDefinitions> 
<Grid.ColumnDefinitions> 
    <ColumnDefinition Width="124" /> 
    <ColumnDefinition Width="246*" /> 
</Grid.ColumnDefinitions> 
<Rectangle Grid.RowSpan="6"/> 
</Grid>