From here https://msdn.microsoft.com/en-us/library/system.windows.data.bindingbase.targetnullvalue(v=vs.110).aspx,
It gives an example of specifying 'TargetNullValue':
<TextBox Width="150"
         Text="{Binding Source={StaticResource object2}, 
  Path=PropertyB, BindingGroupName=bindingGroup, 
  TargetNullValue=please enter a string}" />
My question is how can I specify an empty string for TargetNullValue?
I have tried "TargetNullValue= }" (there is a space between = and }, but that does not work, the target null value is null, instead of an empty string.
Thank you.
I don't know why the answer saying to use '' is deleted, but it works fine for me:
<TextBox Text="{Binding NumberOfCats, TargetNullValue=''}" />
                        You can use x:Static in the xaml and define the string.empty there.
<TextBox Width="150"
         Text="{Binding Source={StaticResource object2}, 
  Path=PropertyB, BindingGroupName=bindingGroup, 
  TargetNullValue={x:Static system:String.Empty} }" />
You'll need to add the appropriate namespace to the xaml as needed. VS should do this for you though. Namespace required is
xmlns:system="clr-namespace:System;assembly=mscorlib"
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With