I need to pass multiple values into the i value converter but since multibinding isn't an option for DataMemberBinding I decided to pass the whole type into the converter as seen below: (I tried to only put the relevent code here)
<telerik:GridViewDataColumn Header="{x:Static properties:Resources.Value}" DataMemberBinding="{Binding Converter={StaticResource myConverterSelector}}" TextAlignment="Center" HeaderTextAlignment="Center" DataType="{x:Type sys:Double}" UniqueName="Value">
public class MyConverterSelector : IValueConverter
{
public object Convert(object item, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
TabularTag tag = item as TabularTag;
if (tag != null)
{
if (tag.Format == "Float" || tag.Format.Contains("REAL") || tag.Format == "")
{
double parsedVal;
if (Double.TryParse(tag.Value.ToString(), out parsedVal))
{
return parsedVal.ToString("f3", CultureInfo.InvariantCulture);
}
}
else
{
double parsedVal;
if (Double.TryParse(tag.Value.ToString(), out parsedVal))
return parsedVal.ToString("f0", CultureInfo.InvariantCulture);
}
}
return null;
}
public object ConvertBack(object item, Type targetType,
object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
}
This works great on the cell data but the filter for this column ends up empty (I attached a snapshot of this) I tried using CellTemplate instead to edit the data but this doesn't affect the filter, which needs to match.