Default Value in MaskedNumericInput preventing EmptyContent

6 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
    1182 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. UI for WPF is Visual Studio 2017 Ready
  4. 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.

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

    Posted 10 May 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>

  7. Peshito
    Admin
    Peshito avatar
    496 posts

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