In one of my project when I was working with Infragistic Grid i.e., XamDataGrid. I need two type of input fields, one should take decimal value in —.– (2 decimal place)format and in other it should be —-.— (3 decimal place)And the second requirement is when I edit the input field and give whole number it should append decimal and zeros after it acc. to the format.
For this I used an approach and tried this code
<igDP:TemplateField Name="WeightProperty" Label="WeightColumn" Width="200" />
Why I am not using regular WPF control? See below the Note Section.
But this could not solve my problem. I may be doing the wrong approach.
Then I use XamNumericEditor Control and its Mask Property , and yes this is what I want. It finally solved my problem.
xmlns:igDP="http://infragistics.com/DataPresenter" xmlns:igED="http://infragistics.com/Editors" <igDP:TemplateField Name="WeightProperty" Label="WeightColumn" Width="200"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igED:XamNumericEditor}" EditAsType="{x:Type System:Decimal}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igED:XamNumericEditor}"> <Setter Property="Mask" Value ="{}{double:4.2}"/> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:TemplateField>
In your project , If you have many places where you have to use this control, Then coping same code in different places is a hectic and error prone task and also it is not a good programming.
So for that you have to create a Custom Control Class and use it like a Control.
See how to do this?