I have a data object with a property that I would like to display and edit as a percentage. I have not been able to get this to work.
<Style TargetType="{x:Type igEditors:XamNumericEditor}"> <Setter Property="ValueConstraint"> <Setter.Value> <igEditors:ValueConstraint MinInclusive="-100" MaxInclusive="100" /> </Setter.Value> </Setter> <Setter Property="Format" Value="P2" /> <Setter Property="Mask" Value="-nnnnnnnnnn.nn %" /> <Setter Property="NullText" Value="-" /> </Style>
If the value of my property is, 0.3333, this style allows my Numeric editor to display "33.33%" in the grid, but when I try to edit, it displays "0.33 %". It appears that the numeric formatting string P2 gets interpreted correctly, whereas, there is no way to tell the editor that the value of the property should be multiplied by 100.0 before displaying. How can I display/edit percentages in the XamDataGrid?
I am facing a similar issue, where the underlyer value for instance is 0.33, however it shows on the grid as 33.33% .
I would want this value to be shown as 0.33%. In short I just want the % to be suffixed to the value.
Is there a simpler way out rather than writing a converter.
You might also want to take a look at this forum thread here:
http://community.infragistics.com/forums/p/14426/54334.aspx#54334
Andrew Smith's approach is better in this scenario, because using Enter/Exit edit mode events, you are actually modifying the underlying dataitem and getting it dirty. Using the converter, this will not happen.
You should be applying the converter to the field that you want to represent percent values.
Hope this helps.
Approach 2 works for me. Thank you very much.
Hello,
Basically, the value is 0.33. So if when the editor enters edit mode, it will show this?I am not able to understand completely your scenario, so maybe you could give us little bit more information on that.
Do you want the value to be 0.33 and display 33% (i.e. the value is converted to percentages) or you want the value to be a percentage (33 - 33%).
There are couple of options here.
1.Use ValueToDisplayText converter to convert 0.33 to 33%. This is to achieve the first thing.
2. If you want when the editor is in edit mode, the value to be displayed as percentage as well, you can handle the EditModeStarting and EditModeEding events. On EditModeStarting you can multiply the value by 100 so that it will appear to be converter to a %, and on EditModeEnding, you will divide by 100, so it is converted back. Setting the Format to "P2" will take care of the rest ( when the editor is not in edit mode)
Has anyone gotten to solve this issue?