I would like to see in the group header of a datagrid some additional information per column. The header consists of a Stackpanel with some sub Stackpanels in it. Due to the fact that the user can adjust the size of the columns of the datagrid I have to adjust the size of the single header parts per binding the width of them to the width of the corresponding column:
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander IsExpanded="False">
<Expander.Header>
<StackPanel Orientation="Horizontal">
<StackPanel
Orientation="Horizontal"
Width="{Binding Source={x:Reference TextCol01}, Path=ActualWidth}" >
<TextBlock Text="{Binding Path=Name}" />
<TextBlock Text=" ("/>
<TextBlock Text="{Binding Path=ItemCount}" FontSize="13" FontWeight="Bold"/>
<TextBlock Text=")"/>
</StackPanel>
<StackPanel
Orientation="Horizontal">
<TextBlock Text="{Binding Path=Name}" />
<TextBlock Text=" ("/>
<TextBlock Text="{Binding Path=ItemCount}" FontSize="13" FontWeight="Bold"/>
<TextBlock Text=")"/>
</StackPanel>
</StackPanel>
</Expander.Header>
<ItemsPresenter />
</Expander>
</ControlTemplate>
Without binding the Width (Width="{Binding Source={x:Reference TextCol01}, Path=ActualWidth}") the binding to the Name and the ItemCount of the CollectionViewGroup works perfect. But with binding the Width it fails.
I suppose it is to do with Binding Source. That changes the context or so. But I don't know what exactly is wrong with it.
Could anyone help? Thank you!