How to set TargetNullValue in a WPF Binding to an empty string when the item is NULL.

You can just set the TargetNullValue to an empty string using a Static.

 <TextBox MinWidth="30" 
Text="{Binding StepRefNo,
             TargetNullValue={x:Static System:String.Empty} }" 

Be sure to add this to your class def at top.

Happpy coding!

Join the Conversation


Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.