If I enter a value into a XamNumericEditor that has a mask of {double:4.2}, and I only enter the first four digits and I tab off it, why doesn't the control fill in the decimal places with 0's?
I just leaves and empty place... Any way to fix that?
You can change the DisplayMode to IncludeBoth so it includes the PromtChar after exiting edit mode e.g.
<ig:XamNumericEditor x:Name="xamNumericEditor1" Width="200" Height="30" ValueType="System:Double" Mask="{}{double:4.2}" PromptChar="0" DisplayMode="IncludeBoth" />
Hope that helps!
Is there a cleaner way ?
With this workaround, if the user types "12.3" it will display "0012.30" when in fact, we need to display "12.30".
In my case, I use the XamNumericEditor to display currency and percentages, so the decimal numbers are really important (12.30$ versus 12.3$ or 0012.30$)
Any other solution ?
Thank you,
Not really, sorry. I think an image's worth a thousand words, so I've attached what is happening and what I expect.
While the control has focus, it is OK to display prompt chars and it does not matter if "12.3" is typed in without the 0 at the end. However, when the control loses focus, I want it to automatically format to "12.30" (a kind of ValueToDisplayTextConverter). However, no DisplayMode allows to do that.
Here's what I do to edit an amount in CAD$ :
<ig:XamNumericEditor Padding="0,0,15,0" Mask="{}{double:6.2}" ValueType="my:Double" PromptChar=" " ValidationMode="Always" Value="{Binding MONTANT, Mode=TwoWay}" Minimum="0" DisplayMode="{Binding MONTANT, Converter={StaticResource neDisplayModeConverter}}" />
<TextBlock Grid.Row="0" Grid.Column="2" Text="$" Margin="0,0,5,0" HorizontalAlignment="Right" VerticalAlignment="Center" />
And here's the converter that allows to display an empty box instead of " . " when the value is null : public class XamNumericEditorDisplayModeConverter : IValueConverter{public object Convert(object value, Type targetType, object parameter, CultureInfo culture){if (value == null || !(value is double)) return Infragistics.Controls.Editors.MaskMode.Raw;else return Infragistics.Controls.Editors.MaskMode.IncludeLiterals;}...}
Is there any way to use a converter or something else to format the text that represents the value when the control is NOT in edit mode (when it does not have focus) ?
Thanks for your help :)
Remove the PromptChar="0"
You no longer see the 0s but you do see lines for digits.
Or set the PromptChar=" " [space], then all you see is the decimal point.
Take a look, does that help? But as far as I can tell, there is no auto filling for the currency.
Thanks,
Richard