I need a checkbox in the header of my datagrid, however I can't seem to align this checkbox.
This is my xaml:
<data:DataGrid
x:Name="myDataGrid"
VerticalAlignment="Top"
Width="300"
Grid.Column="0"
AutoGenerateColumns="False">
<data:DataGrid.Columns>
<data:DataGridCheckBoxColumn Binding="{Binding IsNew}" Width="80">
<data:DataGridCheckBoxColumn.HeaderStyle>
<Style TargetType="dataprimitives:DataGridColumnHeader">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Border Background="Red" Width="80" HorizontalAlignment="Center">
<CheckBox
x:Name="chkAll"
HorizontalAlignment="Center"
HorizontalContentAlignment="Center"
Click="chk_Click">
</CheckBox>
</Border>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</data:DataGridCheckBoxColumn.HeaderStyle>
</data:DataGridCheckBoxColumn>
<data:DataGridTextColumn Header="First Name" Binding="{Binding FirstName}" Width="50" />
<data:DataGridTextColumn Header="Last Name" Binding="{Binding LastName}" Width="100" />
</data:DataGrid.Columns>
A screenshot of my datagrid can be seen at: http://img686.imageshack.us/img686/5109/datagrid.png
I used only the border to illustrate the problem, but I also tried Grid and Stackpanel, and also checked the box directly under the DataTemplate tag, but to no avail. How can I check the center box?
Any help would be greatly appreciated.
Adnan source
share