This project is read-only.

Changing individual headers on DataGrid

Oct 28, 2014 at 4:01 PM

I was looking into changing the horizontal alignment of the header of a single column, but the Header property of DataGridTemplatedColumn.Header only accepts a string.
The ComboBox.Header in WinRT accepts an object so its possible to have a TextBlock as the header and change that.

This is what I would like to accomplish
        Text="{Binding Qty}"
 <!--Only accepts string-->
Oct 29, 2014 at 8:15 AM
It should be easy to change this so that object is used.. Ill look into it in the next days
Nov 5, 2014 at 7:09 PM
Header is now objet in newest commit and can be a UI element => try latest code by downloading from "Source Code" page
Nov 5, 2014 at 7:19 PM
You may also need to change the datagrids HeaderTemplate so that the width of the header is not auto:
                    <Grid Background="Transparent">
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        <ContentPresenter Grid.Column="0" VerticalAlignment="Center" FontSize="26.667" Margin="15,0,15,0" Content="{data:Binding Header}" />
                        <StackPanel Grid.Column="1" Visibility="{Binding IsSelected, Converter={StaticResource vc}}" 
                                    VerticalAlignment="Center" HorizontalAlignment="Left">
                            <Path Data="M5,0 L0,10 L10,10 Z" Fill="White" Visibility="{Binding IsAscending, Converter={StaticResource vc}}"/>
                            <Path Data="M0,0 L5,10 L10,0 Z" Fill="White" Visibility="{Binding IsAscending, Converter={StaticResource nc}}"/>
Nov 6, 2014 at 10:49 AM
I tried this out on the DataGrid sample and works like a charm, great work as usual.