2016-07-06 1 views
0

테이블이있는 FlowDocument가 있습니다. XAML에서 직접 테이블을 만들고 일부 셀 내용을 두 줄로 나누면 모든 셀이 자동으로 맞고 전체 행의 높이가 같습니다.WPF Flow Document : 코드 뒤에 코드를 추가 할 때 셀 높이 조정

enter image description here

<TableRow Name="TestRow"> 
         <TableCell BorderThickness="1,0,1,1" BorderBrush="LightGray"> 
          <Paragraph>1</Paragraph> 
         </TableCell> 
         <TableCell BorderThickness="0,0,1,1" BorderBrush="LightGray"> 
          <Paragraph>This is sentence which is divided into two lines</Paragraph></TableCell> 
         <TableCell BorderThickness="0,0,1,1" BorderBrush="LightGray"> 
          <Paragraph>123</Paragraph></TableCell> 
         <TableCell></TableCell> 
        </TableRow> 
하지만 뒤에 코드에서 동적으로 테이블을 생성 할 때, 세포는 서로 다른 높이를 가지고있다.

tableProducts.RowGroups[0].Rows.Add(new TableRow()); 
     TableRow currentRow = tableProducts.RowGroups[0].Rows[1]; 
     currentRow.Cells.Add(new TableCell(new Paragraph(new Run("1")) { BorderThickness = new Thickness(1, 0, 0, 1), BorderBrush = Brushes.LightGray })); 
     currentRow.Cells.Add(new TableCell(new Paragraph(new Run("This is sentence which is divided into two lines")) { BorderThickness = new Thickness(1, 0, 1, 1), BorderBrush = Brushes.LightGray })); 
     currentRow.Cells.Add(new TableCell(new Paragraph(new Run("123")) { BorderThickness = new Thickness(1, 0, 0, 1), BorderBrush = Brushes.LightGray })); 

enter image description here

나는 그들이 뒤에 코드에서 생성 될 때 세포의 높이를 정렬하는 방법에 대한 해결책을 찾을 수 없습니다. 이 문제를 해결할 방법이 있습니까?

답변

0

new TableCell(new Paragraph(...)) { BorderThickness = ... }로 변경 new TableCell(new Paragraph(...) { BorderThickness = ... }) 그래서 이유는 ParagraphTableCell에서 모든 공간을하지 걸립니다, 그 테두리 셀의 내부입니다. 하지만 TableCell의 테두리를 페인트하면 모든 것이 잘 작동합니다.

+0

감사합니다. cdmnk! 해결책은 아주 간단했습니다. –

관련 문제