在WPF中合并网格列标题

时间:2013-07-24 10:54:57

标签: wpf data-binding wpf-controls

我有一个wpf网格,我想合并两个列标题。我尝试使用下面的代码,这里的问题是列生成为2,但在单元格中是为什么每个列网格线不是可见。任何人都可以回答更好的解决方案来实现这个目标

<toolkit:DataGridTemplateColumn>
   <toolkit:DataGridTemplateColumn.Header>
      <Grid>
         <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
         </Grid.RowDefinitions>
         <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
            <ColumnDefinition/>
         </Grid.ColumnDefinitions>
         <TextBlock Grid.Column="0" Grid.ColumnSpan="3" HorizontalAlignment="Center" Text="Missing from FISAP Summary Part II Section F"/>
         <TextBlock Grid.Column="0" Grid.Row="1" Text="A" Width="60" HorizontalAlignment="Center"/>
         <TextBlock Grid.Column="1" Grid.Row="1" Text="C"  Width="60" HorizontalAlignment="Center"/>
         <TextBlock Grid.Column="2" Grid.Row="1" Text="D"  Width="60" HorizontalAlignment="Center"/>
      </Grid>
   </toolkit:DataGridTemplateColumn.Header>
   <toolkit:DataGridTemplateColumn.CellTemplate>
      <DataTemplate>
         <Grid>
            <Grid.ColumnDefinitions>
               <ColumnDefinition/>
               <ColumnDefinition/>
               <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0" Text="{Binding Path=A}" Width="60" HorizontalAlignment="Right" />
            <TextBlock Grid.Column="1" Text="{Binding Path=C}" Width="60" HorizontalAlignment="Right" />
            <TextBlock Grid.Column="2" Text="{Binding Path=D}" Width="60" HorizontalAlignment="Right" />
         </Grid>
      </DataTemplate>
   </toolkit:DataGridTemplateColumn.CellTemplate>
</toolkit:DataGridTemplateColumn>

enter image description here

0 个答案:

没有答案