I am trying to sort columns by numeric content. A multi-link converter works fine. This solution will set SortMemberPath to null
I tried various ways, and substantially washed the Internet.
The code has been changed from the original for security reasons.
<DataGridTemplateColumn x:Name="avgPriceColumn">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock>
<TextBlock.Text>
<MultiBinding Converter="{StaticResource avgPriceConverter}">
<Binding Path="NumberToDivideBy" />
<Binding Path="TotalDollars" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.SortMemberPath>
<MultiBinding Converter="{StaticResource avgPriceConverter}">
<Binding Path="NumberToDivideBy" />
<Binding Path="TotalDollars" />
</MultiBinding>
</DataGridTemplateColumn.SortMemberPath>
</DataGridTemplateColumn>
EDIT: I found a way to get data binding to work without multitasking, but sorting still doesn't work. Since the DataGrid is bound to a custom class, I take an integer value and convert it, thereby reducing the need for MultiBinding.
<DataGridTextColumn x:Name="avgPriceColumn" Binding="{Binding Converter={StaticResource avgPriceConverter}}" SortMemberPath="{Binding Converter={StaticResource avgPriceConverter}}" />
In both of these parameters, SortMemberPath defaults to Binding, so I don’t need to explicitly define it, since I have
, SortMemberPath null, , , . .
EDIT:
, SortMemberPath,