views:

30

answers:

2

Hi..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

A: 

You either have to implement some sort of value converter (Example) or consider using the TargetNullValue property on the binding (Example)

rudigrobler
A: 

There's not much to work with here, but you can achieve something like this with:

  • DataTrigger
  • ValueConverter
  • EventHandling in Code-Behind
  • Binding on a (dependency-)property in a ViewModel encapsulating your business classes
naacal
I solved it using a value converter..but still helps to know any alternative approach...BTW cant handle in my business class since i am using datatables
biju