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>
Excellent, thank you. It's all sorted now and works great.
XtreemX said: XamMaskedEditor.RegisterDefaultMaskForType(typeof(XamCurrencyEditor), "{nnnn}");
XamMaskedEditor.RegisterDefaultMaskForType(typeof(XamCurrencyEditor), "{nnnn}");
That method is for specifying the mask to use for a given datatype not editor control type. So you would use the target data type. e.g. XamMaskedEditor.RegisterDefaultMaskForType(typeof(decimal), "{nnnn}");
Ah, yes, I had two Styles set in my XamDataGrid.Resources:
<Style TargetType="{x:Type igData:CellValuePresenter}"> <Setter Property="HorizontalContentAlignment" Value="Right"/></Style><Style TargetType="{x:Type igEditors:XamCurrencyEditor}"> <Setter Property="Mask" Value="nnnn"/></Style>
I guess the second one wasn't being picked up. However, I have tried setting the second 'Mask' setting programmatically with the following code as this isn't having any effect either:
...and even:
XamMaskedEditor.RegisterDefaultMaskForType(typeof(XamCurrencyEditor), "{XXXX}");
Am I doing anything wrong?
By the way, I was able to get date and time displayed using the method you mentioned with the following code as a child of 'Field':
<igData:Field.Settings> <igData:FieldSettings> <igData:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamDateTimeEditor}"> <Setter Property="Mask" Value="{}{date} {time}" /> </Style> </igData:FieldSettings.EditorStyle> </igData:FieldSettings></igData:Field.Settings>
So, thank you for that. However, I want to avoid having to do this for each currency field as this is a more general requirement.
Many thanks,
Jason
XtreemX said: But it doesn't appear to be having any effect. Any idea on this?
But it doesn't appear to be having any effect. Any idea on this?
XtreemX said: I've also got some DateTime properties being bound to my XamDataGrid and would like to modify the Mask for these cells too, so that the date and time are displayed rather than just the date, but only for some of the DateTime properties, not all. Is this possible?
I've also got some DateTime properties being bound to my XamDataGrid and would like to modify the Mask for these cells too, so that the date and time are displayed rather than just the date, but only for some of the DateTime properties, not all. Is this possible?
Alex, thanks for your help. Your solution actually fixed another issue I was having with the dates appearing in en-US format; your solution fixed this so that they now appear in en-GB format.
Andrew, thanks for your help too. I prefer the use of an explicit Mask and tried to apply this to my XamDataGrid via a Style as thus:
<igData:XamDataGrid.Resources> <Style TargetType="{x:Type igEditors:XamCurrencyEditor}"> <Setter Property="Mask" Value="nnnn"/> </Style></igData:XamDataGrid.Resources>