I Created the xamdatagird in my case the column are not static it’s dynamically generated in that how can I set all cell are allowed only decimal value I am using MVVM approach it’s there is any way to set that in the View design page itself I saw few post in infragistics there they are directly mentioning the Filed value for example
<igDP:Field Name="pct" Label="Passing %">
<igDP:Field.Settings>
<igDP:FieldSettings EditAsType="{x:Type sys:Double}" />
</igDP:Field.Settings>
</igDP:Field>
In my case it’s not possible because the fields are generated dynamically how I can get this ,I attached the sample project also
Hai Rob,
Thanks for your quick reply its working fine thanks once again you saved my time
Thanks,
Gowthaman.
Hello Gowthaman,
The mask on the underlying editor is restricting how many decimals you can provide to two (this is the default mask). If you want to be able to paste more than 2 decimal places then you either need to place the cell in edit mode first and paste directly into the editor, or change the mask. You can change the mask by providing an editor style to the Field in question.
<Style TargetType="{x:Type igEditors:XamNumericEditor}" x:Key="3DecimalPlaces"> <Setter Property="Mask" Value="{}{double:-9.3}"/> </Style>
field.Settings.EditorStyle = this.Resources["3DecimalPlaces"] as Style;
This will let you paste a number with 3 or less decimal places. Another option would be to handle the pasting operation yourself. Handle the ClipboardPasting event and cancel it. You can use this event to grab the pasted data using the e.DataObject. Once you have the data, you can set the ActiveCell.Value property directly. The value will be truncated according to the mask on the editor.
Hi Rob,
Thanks for your reply okay am using same approach which you suggested in that xamgrid now its allowing only 2 decimal after the dot in my scenario user can copy from the excel document and paste that over the xamgrid that data may contain 3 decimal after the dot in that case it porting the message box Unable to convert the value please enter the valid number continue with the remaining cells? in this case the value should convert automatically or it should allow 3 decimal places how to achieve this any idea please suggest me
Gowthaman
Unfortunately no. The only way to explicitly set the type is through the Field settings. The code I sent does not violate MVVM though. Fields are part of the view so it is entirely acceptable to write code in the code-behind to manipulate the Fields. As long as the view (.xaml + .cs code behind) only touches code pertaining to the UI (Fields) then it is ok. A problem would arise if you tried to set the settings from the view model as your view model would require a reference to a Field which means it knows about the view.
Thanks for your quick response on that Rob Stoffers
It's working fine, you done that through events using the code behind file (.cs) it’s there any way to handle in the viewmodel or xaml(view) design page because am using the MVVM Pattern