1

I am trying to use a purely style-istic approach to getting the sort ordering index in the header of my datagrid. This is the (stripped off) template:

<ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
    <Border Name="Wrapper">
        <StackPanel Margin="6,3,6,3"
                    Orientation="Horizontal"
                    Background="{TemplateBinding Background}">
            <TextBlock VerticalAlignment="Center"
                       FontSize="10"
                       Foreground="{StaticResource TextBrush}">
                <TextBlock.Text>
                    <MultiBinding Converter="{StaticResource SortOrderConverter}">
                        <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Column.SortMemberPath"/>
                        <Binding RelativeSource="{RelativeSource AncestorType={x:Type DataGrid}}" Path="Items.SortDescriptions"/>
                    </MultiBinding>
                </TextBlock.Text>
            </TextBlock>
            <ContentPresenter VerticalAlignment="Center"/>
        </StackPanel>
    </Border>
</ControlTemplate>

SortOrderConverter basically looks up the SortMemberPath in the SortDescriptionCollection and returns a number with a space, or empty string if nothing is found.

My issue is that the binding to the SortDescriptions does not seem to be working. The converter is called once at startup for each column header (as expected), and sorting the datagrid has no effect.

How do I make the multibinding trigger when NotifyCollectionChanged is fired by sorting the datagrid?

vorrr
  • 11
  • 1

0 Answers0