Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set textbox to "nothing" in WPF but MV value not updated

Tags:

wpf

textbox

I have a user interface where a user can enter a value and that value is updated in the ViewModel (and eventually written back to a database).

This works fine if the a value is actually entered. But if you want to clear that value (i.e. set it to nothing) it doesn't seem to work.

So for example if it was 'dog' but I clear that text and "save" the change is not recognized.

I call "PropertyChanged" which is fired if a value is entered. But if the text is cleared, and I hit enter or tab out of the textbox, the property is not updated.

Is there some special way to deal with this or am I just missing something?

thanks

like image 457
code Avatar asked Dec 19 '25 00:12

code


1 Answers

It ought to work....

Are you sure your other layers (especially the DB) accept 'empty' values? It could be a conversion-exception or error being silently eaten.

To diagnose, experiment with different properties of different types.

like image 72
Henk Holterman Avatar answered Dec 21 '25 21:12

Henk Holterman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!