How do I replace a zero (0:00:00) TimeSpan with blanks:
I've tried the following:
DataMemberBinding="{Binding LunchBreak, StringFormat={}0:dd\\.hh\\:mm\\:ss;;''}}"
But I still get 0:00:00
How do I replace a zero (0:00:00) TimeSpan with blanks:
I've tried the following:
DataMemberBinding="{Binding LunchBreak, StringFormat={}0:dd\\.hh\\:mm\\:ss;;''}}"
But I still get 0:00:00
Your code doesn't work for me at all, actually. It throws an error which (ironically) results in a blank output.
Regardless, after some testing and research, it seems as far as I can tell that the semicolon separator is only supported by "numeric" types, and not by TimeSpan. So there's no way to do this with StringFormat alone.
The only ways I can think of to get around this are to create a string property with an if inside to do the conditional formatting yourself, or to create an IValueConverter that does the same. Of the two, I'd recommend the latter.