I need to pass in an extra parameter (DataItem) into my ValueToDisplayTextConverter so each cell can display its value AND unit when not editing, but just value when editing. (Example - show "90%" when not editing, but "90" when editing) So the current value of the cell IS 90, so editing appears correctly. The unit (which could be different for every record) is another field on that record.
<igDP:UnboundField Name="ValueAndUnit" Label="Value"> <igDP:Field.Settings> <igDP:FieldSettings CellMinWidth="80" CellWidth="80" EditorType="{x:Type igEditors:XamNumericEditor}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamNumericEditor}" > <Setter Property="ValueToDisplayTextConverter" Value="{StaticResource ParamValueConverter}"></Setter> <Setter Property="PromptChar" Value=""></Setter> <Setter Property="Mask" Value="{}{double:5.2}"></Setter> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings></igDP:UnboundField><igDP:Field Name="UnitOfMeasure" Visibility="Collapsed" />
If anybody could help, or point me towards something that would help I would appreciate it
Thanks
Thanks Andrew, that was exactly what I needed!
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value != null && value is double) { XamNumericEditor editor = (XamNumericEditor)parameter; DataRecord dr = (DataRecord)editor.DataContext; string unit = dr.Cells["UnitOfMeasure"].Value.ToString(); return value + " " + unit; } else { return null; } }
There is no property to control the parameter but the parameter is always the ValueEditor itself (the XamNumericEditor in this case) so you can get its Host which in this case should be the CellValuePresenter. From that you can get to its Record property and from there to its Cells collection to get to the value of the other cell. Or you can look at the DataContext of the valueeditor which again in this case should be the DataRecord and then get to the Cells collection.