DataGrid questions

Feb 9, 2009 at 4:38 PM

1) The text in the grid rows appears to be vertically aligned to the top of the cells. Any way I can style it to align to the centre of the cells - is the text rendered using TextBlock? Same question for checkboxes...
2) How can I number each row - I guess this involves changing the style of the RowHeader, but I don't see how to introduce a changing index?
3) How can I embed a control into the column header? Do I use the ColumnHeaderStyle? My goal would be to then update the appearance of all cells in the column when the embedded header control changes state?

Thanks in anticipation...
Feb 9, 2009 at 5:27 PM
Edited Feb 9, 2009 at 6:36 PM
I noticed the same issue 1) so I used a DataGridTemplateColumn  with a Textbox instead. Of course, that makes the xaml not so compact...

<wpftoolkit:DataGridTemplateColumn  Header="Description" Width="200*" CanUserReorder="False">
                                <TextBox  VerticalContentAlignment="Bottom"  Text ="{Binding Path=Description}" BorderThickness="0"/>                         

so I specified a CellTemplate -



wpftoolkit:DataGridTemplateColumn Header="Description" Width="200*" CanUserReorder="False" CellTemplate="{StaticResource GridDescriptionCellTemplate}" />
<DataTemplate x:Key="GridDescriptionCellTemplate" >
    <TextBox VerticalContentAlignment="Bottom" Text ="{Binding Path=Description}" BorderThickness="0"/>

Now if I could just specify the binding at the dataGridTemplateColumn (and be able to re-use the template) then all would be well....