How to hide stringformat if data is null How to hide stringformat if data is null wpf wpf

How to hide stringformat if data is null


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}}" />