Question

I have a date and time being displayed in a textblock. It currently displays "Jun. 21 2013 10:30 AM" with this code

<TextBlock
    Style="{StaticResource infoTextBlockStyle}"
    Grid.Row="0"
    Grid.Column="3"
    Text="{Binding SecureMessage.SentTime, Mode=OneWay, StringFormat={}{0:MMM. dd yyyy   h:mm:ss tt}}" />

I want it to display with a comma after the day of the month like this: "Jun. 21, 2013 10:30 AM"

Simply adding a comma after the "dd" generates an error where the trailing format strings cannot be recognized. Is there a way to add a comma to this custom StringFormat?

Was it helpful?

Solution

Wrap format string in single quotes

Text="{Binding StringFormat='{}{0:MMM. dd, yyyy   h:mm:ss tt}'}"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top