locked
How can I bind column header of datagrid? RRS feed

  • Question

  • There is a datagrid in my project. I’d like to bind column header from database. Do you have any idea for binding column header of datagrid? Thanks.
    Thursday, April 9, 2009 6:52 PM

Answers

  • You can try something like this:

    xmlns:dataprimi="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"

    <Style TargetType="dataprimi:DataGridColumnHeader" x:Key="BoundHeader">

    <Setter Property="ContentTemplate">

    <Setter.Value>

    <DataTemplate>

    <TextBlock Text="{Binding Name}"/>

    </DataTemplate>

    </Setter.Value>

    </Setter>

    </Style>

    Gunjan [MSFT]

    Thursday, April 9, 2009 8:59 PM