What I am trying to do is set the number of decimal places for a cell in one column, based on the corresponding row in another column. But I still need the first column to allow sorting after it has been converted.
The first thing I tried was using an IValueConverter. Here is the XAML:
<Window.Resources>
<src:DataValueConverter x:Key="dataValueConverter" />
</Window.Resources>
<Grid>
<DataGrid x:Name="dataGrid" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Id" Binding="{Binding Id}"></DataGridTextColumn>
<DataGridTextColumn Header="Humidity" Binding="{Binding Humidity, Converter={StaticResource dataValueConverter}"></DataGridTextColumn>
<DataGridTextColumn Header="Version" Binding="{Binding Version}"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
Here I want the number of decimal places in the humidity value based on the value in version. So I tried passing version to ConverterParameter, and then quickly discovered that it does not accept bindings.
I tried using MultiBinding with MultiValueConverter as suggested Binding ConverterParameter. It did show the different decimal places, however the column could no longer be sorted. Also tried this bindable ConverterParameter http://www.codeproject.com/Articles/456589/Bindable-Converter-Parameter, giving the same results.
So is it possible to fill the ConverterParameter to get the desired results?
<DataGridTextColumn Header="Humidity" Binding="{Binding Humidity, Converter={StaticResource dataValueConverter}, ConverterParameter=???}">