I’m using a WatermarkTextBox and I’m binding it’s value to a View Model integer property. The thing is: I need that if there’s no value set then the WatermarkTextBox must show the watermark but, given that it’s bind to an integer when there’s no value set (like when the view is shown) then it shows 0.
I can’t use OneWayToSource cause I need two way binding. Any idea?
You can use a converter. If the value is 0, the converter returns an empty string, which makes the watermark visible. If it’s not 0, it returns the string representation of the number.
Another option is to change the property to
int?(Nullable<int>), and set its initial value to null.