Default Value in MaskedNumericInput preventing EmptyContent

8 posts, 0 answers
  1. Patrick
    Patrick avatar
    42 posts
    Member since:
    Jul 2012

    Posted 03 May 2013 Link to this post

    I have the below XAML declaration in an empty project.  When I run it the below defaults to a 0 instead of what I set the "EmptyContent" to.  If I click the "ClearContent Button" in the control than I will see my "EmptyContent" text.  What am I doing wrong?  Is this a bug or am I just using it wrong?

    <telerik:RadMaskedNumericInput x:Name="Units"
          EmptyContent="Enter Total Units"
          InputBehavior="Insert"
          SelectionOnFocus="SelectAll"
          TextMode="PlainText"                                               
          Mask="#####"
          Margin="3"
          Grid.Column="3"
          Grid.Row="2"/>

    Thanks
  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1251 posts

    Posted 08 May 2013 Link to this post

    Hi Patrick,

    The EmptyContent string is visualized when the Value property of the control is null. It is set to null when you click the clear button. However, initially the Value is 0. In order to show the EmptyContent string you can set the Value of the control to null in its Loaded event handler.

    Please give this approach a try and let us know if it works for you.

    Regards,
    Pavel R. Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Michael
    Michael avatar
    12 posts
    Member since:
    Dec 2010

    Posted 03 Nov 2015 Link to this post

    Thats one of the moments i really don't like telerik controls.

    I bind the value to a object that gives back NULL. Then you set the Element to 0. And then i have to reset it to null. In a dialogue made entirely by dynamic elements i cannot address directly because they have no name. In a dialogue where the elements can either be 0 or null. In MVVM, where i have to write a behavior class just to catch the Loaded Handler just to connect the field to its value AGAIN.

    And then... after doing all this... the default EmptyText is BLACK while it is grey on other input fields like "radwatermarkinput".  Now i have to change the emptycontenttemplate just to display it in the same color.

    This is more work than doing it without telerik.

  4. Peshito
    Admin
    Peshito avatar
    586 posts

    Posted 06 Nov 2015 Link to this post

    Hello,

    Please find attached a sample project demonstrating a MaskedNumericInput control having its Value bound to a nullable double property of the ViewModel. It has it's value initially set to null and the EmptyContent message is properly displayed. In the sample there is also a TextBlock with Text bound to maskedinput's control Value property just to assure that its value is null. Could you update the project so the issue you have becomes reproducible or simply attach a runnable copy of yours. As this is a forum thread you should use a third party web site for files sharing or submit a support ticket regarding this inquiry.

    As for the EmptyContent text color, what is the theme you have been using? We try to keep our themes consistent and I will gladly forward this to our developers.

    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
  5. boone
    boone avatar
    3 posts
    Member since:
    Oct 2006

    Posted 10 May 2016 in reply to Peshito Link to this post

    This does not work with RadMaskedCurrencyInput. Try:

    <Window x:Class="NumericInputValueBinding.MainWindow"   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"   Title="MainWindow"  Height="350"    Width="525">
        <Grid>
    <StackPanel>
    <telerik:RadMaskedCurrencyInput x:Name="Units" Value="{Binding TestValue, Mode=TwoWay}"  EmptyContent="Enter Total Units"  Mask="" FormatString="c" /><TextBlock Text="VALUE: " /><TextBlock Text="{Binding Value, ElementName=Units}" /></StackPanel></Grid></Window>

  6. Peshito
    Admin
    Peshito avatar
    586 posts

    Posted 11 May 2016 Link to this post

    Hi,

    The Value type of RadMaskedCurrenctyInput is decimal. Simply change the type of the property you have bound to, to be nullable decimal instead of nullable double.

    Hope this helps.

    Regards,
    Peshito
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  7. Michael
    Michael avatar
    1 posts
    Member since:
    May 2018

    Posted 22 May 2018 Link to this post

    Using telerik:RadMaskedNumericInput

    Trying to display a Number with up to 3 decimal places ... With AutoFillZeros set to false.. I still get a value with .000.. 

     

     EmptyContent="Item"                                          InputBehavior="Replace"                                     AutoFillZeros = "False"                                         AutoFillNumberGroupSeparators="False"           FormatString="n3"
     Mask=""                                          TextMode="PlainText" 

    Value="{Binding Value}"

  8. Petar Mladenov
    Admin
    Petar Mladenov avatar
    3152 posts

    Posted 25 May 2018 Link to this post

    Hi Michael,

    AutoFillZeros is by default False for the RadMaskedNumericInput but is designed for scenarios with non-empty Mask.

    To change the decimal places after the decimal point you need to play with the FormatString and change it dynamically - N0, N1, N2 etc. We have an SDK sample demonstrating such approach. Could you please take a look and let us know if it gives you a good starting point ?

    MaskedInput: Dynamic Format String

    Regards,
    Petar Mladenov
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top