String Formatting

Topics: Getting Started
Jun 2, 2011 at 9:58 PM

I'm just getting started with CM and have got some basic views/viewmodels and a conductor working.  I'm wondering though...how do you do string formatting?  I can automatically bind to strings and ints...but what about decimals for currency?  In those cases do I just have to fall back to Text={Binding Salary, StringFormat=c2}, or is there some fancy CM way to do it that I'm missing?

Oct 29, 2011 at 6:41 PM

As far as I can tell from a quick look at the source, the only automagical string formatting that takes place is if the bound property is of type DateTime and if so the standard US dateformat "MM/dd/yyyy" is applied. I was hoping for something a long the lines of this;

<TextBlock x:Name="CustomerName"  Text="Hello, {0}"/>
... but that doesn't seem to work even though that would be truly awesome. Then you could even have things like format specifier {0:c2}. And even better; take in to account that not everyone uses the US dateformat.

Oct 29, 2011 at 8:53 PM

ValueConverter.....