How to put bound data (Binding) into a Grid View Header or List View Header.

This is another seemingly simple task. It actually is, but you may go down the route of setting the GridViewHeader.Template and wondering why it doesn’t work.

Well, it’s as simple as putting a GridViewHeader into the GridViewColumn definition and setting content to it.

<GridViewColumn  Width="Auto">
    <GridViewColumnHeader>
        <Grid HorizontalAlignment="Right" >
                <Grid.RowDefinitions>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <TextBlock Text="{Binding Title, Mode=OneWay}" Grid.Row="0" HorizontalAlignment="Right" />
             </Grid>
    </GridViewColumnHeader>
</GridViewColumn>

See. Nice and easy right? Just fill in the different UI controls you want to make it fit your needs and away you go.

Happy Coding!

Leave a Reply

Your email address will not be published. Required fields are marked *