I am binding an object to a XamDataPresenter and one of the properties is of decimal type. At run-time, it displays with commas separating the thousands and a dollar in front of the value. How do I stop this?
I tried explicitly defining the field, but this didn't help:
<igData:XamDataPresenter Name="dpMyData" DataSource="{Binding}"> <igData:XamDataPresenter.FieldLayoutSettings> <igData:FieldLayoutSettings AutoGenerateFields="False" /> </igData:XamDataPresenter.FieldLayoutSettings> <igData:XamDataPresenter.FieldLayouts> <igData:FieldLayout> <igData:FieldLayout.Fields> <igData:Field Name="MyField" DataType="{x:Type sys:Decimal}" /> </igData:FieldLayout.Fields> </igData:FieldLayout> </igData:XamDataPresenter.FieldLayouts></igData:XamDataPresenter>
If you specify an explicit Mask then you would not get a currency symbol (unless you include one in the mask). Also, you can use a static method (RegisterDefaultMaskForType) to change the default mask that is used for particular data types.
Hello Jason,
I am not sure if you can keep the field as XamCurrencyEditor and remove the sign at the same time, but you can change it with the FormatProvider property. Here is a thread on this topic. Hope this helps.
http://forums.infragistics.com/forums/p/21225/76417.aspx#76417
Alex.
Thanks Alex,
I ended up going with the option provided by Developer Support for my case because there were actually some cases where I wanted a decimal to be represented by a XamCurrencyEditor.
Just another quick question for you though you may know the answer to in your infinite wisdom :) ...
In the cases I want it to be represented by a XamCurrencyEditor, how do I change the currency, or even remove the currency sign altogether but still keep it as a XamCurrencyEditor?
Thanks,
Jason
Hello,
Yes this is almost the same way to do that and it is up to you to choose between the two ways.
If you want, you can change the EditorStyle and EditAsType like they have shown, but :
1) you will change the data type of the field
2) you will have to do this for every field you want to do this.
By registering a different XamEditor for a ValueType you will not change the data type (from decimal to double) and you will not have to repeat changing the EditorType for every field.
Alex
Hi Alex,
Thanks for your help here. I had a reply from Infragistics Developer Support, which is probably along the lines of your other thread where you answered a similar question. They said:
The reason you are getting the currency symbol in your decimal field is because the default editor for a decimal field in the XamDataGrid is the XamCurrencyEditor. However, you can change this by setting the Field's EditorType property to use the XamNumericEditor. You can use the following xaml code snippet:
<igData:XamDataGrid Margin="31,12,56,43" Name="xamDataPresenter1" > <igData:XamDataGrid.FieldLayoutSettings> <igData:FieldLayoutSettings AutoGenerateFields="False" /> </igData:XamDataGrid.FieldLayoutSettings> <igData:XamDataGrid.FieldLayouts> <igData:FieldLayout> <igData:FieldLayout.Fields> <igData:Field Name="MyField"> <igData:Field.Settings> <igData:FieldSettings EditorType="{x:Type igEditors:XamNumericEditor}" EditAsType="{x:Type sys:Double}" /> </igData:Field.Settings> </igData:Field> <igData:Field Name="Name" /> </igData:FieldLayout.Fields> </igData:FieldLayout> </igData:XamDataGrid.FieldLayouts> </igData:XamDataGrid>
For more Information you may refer the following online help article:
<http://help.infragistics.com/Help/NetAdvantage/WPF/2008.2/CLR3.X/html/xamData_Default_Editor_Types_for_Different_Data_Types.html>