I have the following in xamDataGrid resources:
<Style x:Key="NumberStyle" TargetType="{x:Type igEditors:XamTextEditor}"> <Style.Setters> <Setter Property="Format" Value="#,##0.00"/> <Setter Property="InvalidValueBehavior" Value="RetainValue" /> <Setter Property="HorizontalContentAlignment" Value="Right"/> </Style.Setters> </Style>
And following field:
<igDP:UnboundField Name="PriceLocal" Width="70" Label="Price" Column="5" > <igDP:UnboundField.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamTextEditor}" EditorStyle="{StaticResource NumberStyle}" ></igDP:FieldSettings> </igDP:UnboundField.Settings> </igDP:UnboundField>
The above works for bound field but not for unbound field - please help!
Thanks.
Hello Jay6447,
Thank you for your post!
I have been looking into it and have created a small sample application in order to test the functionality you have reported. In the sample application I have an UnboundField, that the style that you have provided in your initial post, in the Resources of the XamDataGrid.
Using this sample application I was not able to reproduce the issue you have reported. I am attaching the sample I have been testing with for your reference.
Would you please modify it with the functionality you are using, so it reproduces the issue? This way I would be able to further investigate this matter for you.
Looking forward to hearing from you.
Thanks for the prompt reply. I think, the issue is when you have both bound and unbound fields in the xamDataGrid. The style works fine with the bound fields but not with the unbound fields.
With my WPF programming skill level, it will take me a while to to construct a sample app. It would be great if you could add 1 unbound field to your xamDataGrid and test it. BTW, I am not using ViewModel - my xamDataGrid is bound to a DataTable using (xgrdMain.DataSource = dt.DefaultView).
Okay, I have updated your sample app to show the issue - attached...
I have been further researching this issue for you. What I can suggest is setting the EditAsType property for the UnboundField to be Decimal. Also I can suggest setting the EditorType for the UnboundField to be XamNumericEditor.
This way the formatting would apply.
Here is an example of the code, that you can use:
<igDP:UnboundField Name="Age" >
<igDP:UnboundField.Settings>
<igDP:FieldSettings EditorType="{x:Type igEditors:XamNumericEditor}"
EditAsType="{x:Type sys:Decimal}"
EditorStyle="{StaticResource NumberStyle}" >
</igDP:FieldSettings>
</igDP:UnboundField.Settings>
</igDP:UnboundField>
Please do not hesitate to let me know if you have any further questions on this matter.
I checked your video - there is a problem. The formatting of the Age field should be "#,##0.00" but it is showing as just 1000 (without comma and 2 decimal places).
Salary field is formatted correctly but not the Age field.
You can change the values of both salary and age fields to large decimal nos like 12123232.2222 and try it.
Thank you for the provided code snippets.
I have used them to create a sample application. In the sample application, when I click on the "Click Me" button the data for the 'Age' field is added and the style is applied.
I have created a video for you to see this behavior on my side. Would you please provide me with more detailed information regarding the environment in which you are developing your application (Operating system, Service Release, Integrated development environment and the specific version of our product that you are using and any other information that might help reproducing your issue), in order to be able to identify what might be causing this behavior?
Try this - I have only attached the mainwindow.xaml and code behind files. You can probably just select-all and copy-paste the contents of both these files to your sample app. I have replaced the VM with a DataTable. The "Click Me" button will show the problem.
I have been looking into your posts. I have downloaded the sample application you were referring to in your latest post. When I open it, there is no code, just an empty project.
Would you please let me know if I am missing something?