+1  A: 

No, there's no way to do that.

John Saunders
Unfortunately, this is the most concise and correct answer to my questions. The other suggestions would be nice workarounds, but unfortunately they are no option for me.
Daan
If you had the option to bind to a type other than string, then you could override the ToString() method on that type to do what you wanted. If you can wrap your string in such a type, that would work.
John Saunders
+4  A: 

Why not just this?

string.Format("Toelichting: {0}", string.IsNullOrEmpty(explanation) ? "–" : explanation);

I don't think there's a way to embed this within the format string.

David M
I cannot do this, because I have no control over the actual assignment of the text to the control, as it is part of a more complex, composite control. That is why I tried to embed this logic in the FormatString.
Daan
Ah. In that case, I'm afraid you'd need to replace an empty string with an en-dash as you retrieve the data. Sorry.
David M
+1  A: 

You can do it like this:

String.Format("Toelichting: {0}", 
    (String.IsNullOrEmpty(yourstr)) ? "-" : yourstr);

Not perfect but its relatively compact and readable.

Andrew Hare
I cannot do this, because I have no control over the actual assignment of the text to the control, as it is part of a more complex, composite control. That is why I tried to embed this logic in the FormatString.
Daan
+1  A: 

If you're doing this sort of thing a lot then consider writing your own formatter so that you could write code like this...

foo = string.Format(new MyFormatter(), "Toelichting: {0:explanation}", bar);

MyFormatter would implement IFormatProvider and ICustomFormatter.

Check out this...

http://stackoverflow.com/questions/357447/-net-is-there-a-string-format-form-for-inserting-the-value-of-an-object-property

... which is probably more complicated than you need (as it deals with reflection and works with any object)

Martin Peck