Trying to format a datetime bound value in my XAML using Silverlight 5 like so:

<TextBlock Text="{Binding ContactDate, Mode=OneWay, StringFormat={}{0:'dd/MM/yyyy'}}" Margin="5,0" />

I'm getting the following error: Unexpected Token after end of Markup Extension.

This is driving me insane!

有帮助吗?

解决方案

Try: Text="{Binding ContactDate, Mode=OneWay, StringFormat='{}{0:dd/MM/yyyy}'}"

Unless you mean that you want singlequotes before and after the date string.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top