I have a datagrid with a textcolum using a MultiValueConverter. The converter got 2 values. The first depend of the current Item and the second of a TextBlock. The value displayed is what I want.
<TextBox x:Name="phases"></TextBox>
<DataGrid AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserResizeRows="False"
ItemsSource="{Binding MySource}" RowDetailsVisibilityMode="Collapsed" RowHeaderWidth="0"
SelectionMode="Single">
<DataGrid.Columns>
<DataGridTextColumn Width="Auto" Header="Pos">
<DataGridTextColumn.Binding>
<MultiBinding Converter="{StaticResource MyMultiValueConverter}">
<Binding ElementName="phases" Path="Text" />
<Binding />
</MultiBinding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid >
The Value display in the column is what I want.
The problem is that I can't sort by this colum.
I try to add something like that:
<DataGridTextColumn.SortMemberPath>
<MultiBinding Converter="{StaticResource MyMultiValueConverter}">
<Binding ElementName="phases" Path="Text" />
<Binding />
</MultiBinding>
</DataGridTextColumn.SortMemberPath>
But I get an "Cannot find governing FrameworkElement or FrameworkContentElement for target element." error. I change to:
<DataGridTextColumn.SortMemberPath>
<MultiBinding Converter="{StaticResource MyMultiValueConverter}">
<Binding Path="Text" Source="{x:Reference phases}" />
<Binding Path="" />
</MultiBinding>
</DataGridTextColumn.SortMemberPath>
Then the first line is ok, but for the second, I can't get the currentItem.
I try to used SortEvent, but I can only add SortDescription without any logic ( I have it in my converter).
Is any way to sort a column when using a multiValueConverter?