我正在尝试使用纯粹的风格主义方法来获取我的数据网格标题中的排序索引。这是(剥离的)模板:
<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 基本上是在 SortDescriptionCollection 中查找 SortMemberPath 并返回一个带空格的数字,如果没有找到则返回空字符串。
我的问题是与 SortDescriptions 的绑定似乎不起作用。该转换器在启动时为每个列标题调用一次(如预期的那样),并且对数据网格进行排序没有效果。
当通过排序数据网格触发 NotifyCollectionChanged 时,如何进行多重绑定触发器?