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

Default Value in MaskedNumericInput preventing EmptyContent

7 Answers 583 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 2
Patrick asked on 03 May 2013, 05:37 PM
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

7 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 08 May 2013, 06:22 AM
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.

0
BKR AG
Top achievements
Rank 1
answered on 03 Nov 2015, 01:01 PM

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.

0
Peshito
Telerik team
answered on 06 Nov 2015, 09:47 AM
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
0
boone
Top achievements
Rank 1
answered on 10 May 2016, 04:55 PM

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>

0
Peshito
Telerik team
answered on 11 May 2016, 12:27 PM
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.
0
Michael
Top achievements
Rank 1
answered on 22 May 2018, 07:50 PM

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

0
Petar Mladenov
Telerik team
answered on 25 May 2018, 08:30 AM
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.
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Patrick
Top achievements
Rank 2
Answers by
Pavel R. Pavlov
Telerik team
BKR AG
Top achievements
Rank 1
Peshito
Telerik team
boone
Top achievements
Rank 1
Michael
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or