How can I center align the content of a header template for a Silverlight 3 datagrid? -
I want a checkbox in the header of my datagrid, however, I can not see the center in the alignment of the checkbox.
This is my xaml:
& lt; Data: DataGrid x: name = "myDataGrid" vertical alignment = "top" width = "300" grid. Column = "0" AutoGenerateColumns = "false" & gt; & Lt; Data: DataGrid.Columns & gt; & Lt; Data: DataGridCheckBoxColumn binding = "{Binding IsNew}" width = "80" & gt; & Lt; Data: DataGridCheckBoxColumn.HeaderStyle & gt; & Lt; Style TargetType = "Dotetramm: Datagrams Column Headers" & gt; & Lt; Setter Property = "Content Template" & gt; & Lt; Setter.Value & gt; & Lt; DataTemplate & gt; & Lt; Border background = "red" width = "80" horizontal align = "center" & gt; & Lt; Checkbox x: name = "chkAll" horizontal alignment = "center" horizontal alignment = "center" click = "chk_Click" & gt; & Lt; / Check box & gt; & Lt; / Border & gt; & Lt; / DataTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt; & Lt; / Data: DataGridCheckBoxColumn.HeaderStyle & gt; & Lt; / Data: DataGridCheckBoxColumn & gt; & Lt; Data: DataGridTextColumn header = "first name" binding = "{binding firstname}" width = "50" /> & Lt; Data: DataGridTextColumn header = "last name" binding = "{binding last name}" width = "100" /> & Lt; / Data: DataGrid.Columns & gt;
A screenshot of my datagrid can be found here:
I used the limit to describe only the problem, but I have also tried a grid and stackpanel, as well as keeping the checkbox directly under the Datatapplet tag, everyone has no avail. How do I get a checkbox in the center?
Any help would be greatly appreciated.
The problem is the default control DataGridColumnHeader
For the right side there is a 12 pixel provision to remove your border
and add margin = "12,0,0,0"
in the check box and line it up.
Comments
Post a Comment