RadMaskedNumericInput does not bind decimal datatype correctly

2 posts, 0 answers
  1. Sagar
    Sagar avatar
    11 posts
    Member since:
    May 2014

    Posted 15 Jul 2015 Link to this post

    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"/>

  2. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 16 Jul 2015 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top