This is a migrated thread and some comments may be shown as answers.

RadMaskedNumericInput does not bind decimal datatype correctly

1 Answer 316 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Sagar
Top achievements
Rank 1
Sagar asked on 15 Jul 2015, 11:33 AM

Hi,

  I am using RadMaskedNumericInput control for Percent input. I have decimal datatype property bound to the control. When i try to update value in control as number 55, it updates the background property as "0.55".

 

<telerik:RadMaskedNumericInput x:Name="uxPercentToPay" Grid.Row="6" Grid.Column="1" Margin="2,3" Width="120" Style="{StaticResource RadMaskedNumericInputStyle}" Validation.ErrorTemplate="{x:Null}"   UpdateValueEvent="PropertyChanged" AutoFillNumberGroupSeparators="False" MaskedInput:MaskedInputExtensions.Maximum="100"MaskedInput:MaskedInputExtensions.Minimum="0" Mask="p2.2" Placeholder=" " AutoFillZeros="True"
Value="{Binding PercentToPay,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                               MaskedInput:MaskedInputExtensions.IsEditorTabStop="True"/>
 

Background property:

 

public decimal PercentToPay
        {
            get
            {
                return _percentToPay;
            }
 
            set
            {
                if (_percentToPay == value)
                {
                    return;
                }
 
                _percentToPay = value;
                RaisePropertyChanged(() => PercentToPay);
            }
        }

 

 Please let me know, what could be the possible miss out here.

 

Thanks in Advance,

Sagar

 

 

 

<telerik:RadMaskedNumericInput x:Name="uxPercentToPay" Grid.Row="6" Grid.Column="1" Margin="2,3" Width="120" Style="{StaticResource RadMaskedNumericInputStyle}" Validation.ErrorTemplate="{x:Null}"   UpdateValueEvent="PropertyChanged" AutoFillNumberGroupSeparators="False" MaskedInput:MaskedInputExtensions.Maximum="100"MaskedInput:MaskedInputExtensions.Minimum="0" Mask="p2.2" Placeholder=" " AutoFillZeros="True" 
Value="{Binding PercentToPay,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                               MaskedInput:MaskedInputExtensions.IsEditorTabStop="True"/>

<telerik:RadMaskedNumericInput x:Name="uxPercentToPay" Grid.Row="6" Grid.Column="1" Margin="2,3" Width="120" Style="{StaticResource RadMaskedNumericInputStyle}" Validation.ErrorTemplate="{x:Null}"   UpdateValueEvent="PropertyChanged" AutoFillNumberGroupSeparators="False" MaskedInput:MaskedInputExtensions.Maximum="100"MaskedInput:MaskedInputExtensions.Minimum="0" Mask="p2.2" Placeholder=" " AutoFillZeros="True" 
Value="{Binding PercentToPay,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                               MaskedInput:MaskedInputExtensions.IsEditorTabStop="True"/>

<telerik:RadMaskedNumericInput x:Name="uxPercentToPay" Grid.Row="6" Grid.Column="1" Margin="2,3" Width="120" Style="{StaticResource RadMaskedNumericInputStyle}" Validation.ErrorTemplate="{x:Null}"   UpdateValueEvent="PropertyChanged" AutoFillNumberGroupSeparators="False" MaskedInput:MaskedInputExtensions.Maximum="100"MaskedInput:MaskedInputExtensions.Minimum="0" Mask="p2.2" Placeholder=" " AutoFillZeros="True" 
Value="{Binding PercentToPay,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                               MaskedInput:MaskedInputExtensions.IsEditorTabStop="True"/>

1 Answer, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 16 Jul 2015, 09:09 AM
Hi Sagar,

RadMaskedNumericInput is designed to work with numbers and its Value property is of type nullable double. However, for your scenario you are working with decimal and we recommend  using the RadMaskedCurrencyInput instead.

You could then either use the FormatString="P2" property or customize the currency symbol for the mask as shown below:
CultureInfo culture = new CultureInfo("en-US");
culture.NumberFormat.CurrencySymbol = "%";
culture.NumberFormat.CurrencyPositivePattern = 1;
this.uxPercentToPay.Culture = culture;
Please let me know if any further questions arise.

Regards,
Peshito
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Sagar
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Share this question
or