Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
705
XamGrid HeaderTemplate and HeaderText
posted

Hi,

this is my code:

<ig:XamGrid ItemsSource="{Binding MySource}" AutoGenerateColumns="False">
    <ig:XamGrid.Columns>
        <ig:TextColumn Key="ID" HeaderText="Test" IsReadOnly="True" HeaderTemplate="{StaticResource myTemplate}" />
        </ig:XamGrid.Columns>
    </ig:XamGrid>

And this is my template:

<DataTemplate x:Key="myTemplate">
    <StackPanel Orientation="Horizontal">
        <TextBlock Text="{Binding }" />
        <TextBlock Text="NEW" FontSize="8" Margin="2,0,0,0" Foreground="#FF6394B7" />
    </StackPanel>
</DataTemplate>

If I use this, the actual headertext is ID but it should be Test.
So, how can I bind the text in the TextBlock object to the headertext property?

Parents
  • 35319
    posted

    Hello broeckerS,

     

    I have been looking into your post and since the DataContext of the Header’s DataTemplate is the Key of the Column, we cannot bind to the HeaderText of the Column. This is discussed in the following tread :

     

    http://blogs.infragistics.com/forums/t/33593.aspx

     

    I can suggest accessing the HeaderText in code-behind handling the ‘LoadEvent’ of the TextBlock like :

     

    private void TextBlock_Loaded_1(object sender, RoutedEventArgs e)

            {

                (sender as TextBlock).Text = (((sender as TextBlock).Parent as StackPanel).Parent as HeaderCellControl).Column.HeaderText;

            }

     

    If you have any other questions, feel free to ask.

Reply Children