How to hide a stringformat when data is not present.Consider this sample
<TextBlock Text="{Binding Amount, StringFormat=Total: {0:C}}" />
in this case if Amount is null,Then it will show just Total:.How to hide this if Amount is null or empty
You either have to implement some sort of value converter (Example) or consider using the TargetNullValue property on the binding (Example)
"TargetNullValue" is what i was looking for.I ended up with this and it worked like a charm
<TextBlock VerticalAlignment="Top"
Text="{Binding Path=TotalMonths,
TargetNullValue={x:Static System:String.Empty},
StringFormat=Total: {0:C}}" />
TargetNullValue=''
Will do also
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