Hello,
In xamdatagrid, On click of a button, I need to convert all 0(int,double and decimals) into blank . To implement this i created a style in C# and set ValueToTextConverterProperty and changes it value into the converter as per the cell value but it's not updating the value in the grid.
If column contains 0.00 then it converts to 0 otherwise it's retaining it's old value.
//Code I've written to set ValueToTextConverterProperty :
Style appliedStyleOnSelectedField = SelectedField.Settings.EditorStyle; //Selected field is the column of xamdatagrid
var newSetter = new Setter(ValueEditor.ValueToTextConverterProperty, new ZeroToBlankConverter());
appliedStyleOnSelectedField.Setters.Add(newSetter); SelectedField.Settings.EditorStyle = appliedStyleOnSelectedField ;
Anyone know why is this behaving so weird ?
I have been looking into your post and it seems that you have not set a style for the EditorStyle. This is why it is null. I have create a sample application(DataGridValueToTextConverterProperty.zip) where I have achieve the desired dictionary.
If you need any further assistance on this matter, feel free to ask.
I tried your solution but it only removes 0 after decimal point. I tried to edit your values to 0.00 in the grid itself and then clicks on button1 but value i see in the grid is 0 only.
I did some modifications after that in your converter and tried to return value ( 5, string.empty and null) but it always removing 0 after decimal point. E.g if i am returning value string.Empty or return 8 then it must set empty / 8 value in all rows of the grid. It's not doing that Can you please explain what exactly ValueToTextConverterProperty does ?
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return string.Empty;
}
Looking for your reply
Hello Saurabh,
I have been looking into your post and ‘ValueToTextConverter’ property is used when the editor is in edit mode. The property that you are looking for is ‘ValueToDisplayTextConverter’which is used when the editor is not in edit mode. For more information please take a look at the following links from our online documentation :
http://help.infragistics.com/Help/NetAdvantage/Silverlight/2012.1/CLR4.0/html/InfragisticsSL5.Controls.Editors.XamMaskedInput.v12.1~Infragistics.Controls.Editors.ValueInput~ValueToTextConverter.html
http://help.infragistics.com/Help/NetAdvantage/WPF/2011.2/CLR4.0/html/InfragisticsWPF4.Editors.v11.2~Infragistics.Windows.Editors.TextEditorBase~ValueToDisplayTextConverter.html
I am attaching a modified version of my sample application(DataGridValueToTextConverterPropertyModified.zip).
If you have any other questions on this matter, feel free to ask.
Hello Yanko,
Thanks for your reply. that really helps. Now I've used ‘ValueToDisplayTextConverter’ and that works great for me.
Thanks,
Saurabh Singh