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.
xmlns:System=”clr-namespace:System;assembly=mscorlib”

Happpy coding!

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

Leave a Reply

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