I have the following XAML for creating a datagrid:
<DataGrid CanUserAddRows="False" HorizontalAlignment="Left" Name="Test" AutoGenerateColumns="False" Height="164" Margin="205,264,0,0" VerticalAlignment="Top" Width="511">
<DataGrid.Columns>
<DataGridTextColumn CanUserSort="False" Binding="{Binding Description, Mode=TwoWay}" Header="Description" Width="6*" IsReadOnly="True" />
<DataGridTemplateColumn Width="2.6*" x:Name="Parent" >
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate >
<Grid ShowGridLines="False" Width="{Binding ElementName=Parent,Path=Width}" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<TextBlock Text="Initial " Grid.Column="0" />
<TextBlock Text="Date " Grid.Column="1" />
</Grid>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridCheckBoxColumn CanUserSort="False" Binding="{Binding StepComplete, Mode=TwoWay}" Header="Completed" Width="1.5*" IsReadOnly="True" />
</DataGrid.Columns>
</DataGrid>
I have created a DataGridTemplateColumn.HeaderTemplate with a DataTemplate inside as I want to create a multi header column. My issue is that I cannot get the DataTemplate to stretch / fill its parent cell. I have added an image below to demonstrate my problem. Please note the area highlighted around the Initial Date text as this is the DataTemplate border. Does anyone know how I can change the DataTemplate to fill its parent cell?
Thanks Callum