NumericTextBox default to blank when 0 when using MVVM

I currently have an application in UWP using a MVVM pattern. In the view I have created a Numeric Text Box:

<editors:SfNumericTextBox FormatString=".0000" AllowNull="True" Value="{Binding HeightValue, Mode=TwoWay}" Style="{StaticResource SfTextBoxEntry}" GotFocus="GotFocus"  />

The HeightValue is a double property in the ViewModel that of course can never be null. But what I would like to do is if the user has not entered any value in the numericTextBox for the display to be empty, but because the binding property defaults to 0 (Since it can never be null), I never can get a blank box.
I would prefer to not create a string property wrapper to HeightValue property, but I was wondering if there was a way to default the box to empty or display blank if 0?


1 Reply

SS Sridevi Sivakumar Syncfusion Team November 30, 2017 12:35 PM UTC

Hi Ericka Opp,

#Query :Default the box to empty or Display blank if 0 
Yes.Its Possible.Use double Datatype to Nullable<Double> Datatype.

Nullable<Double> Datatype  is nothing but  which you can assign normal range of values as well as null values.We can display blank box use this datatype. 
Please find the sample from the below link.   
 
Regards
Sridevi S 
  
  


Loader.
Up arrow icon