Binding with StringFormat on Windows Phone 7?

I am developing Windows Phone 7 and want to format the string that I attached to.

For some reason, I cannot use StringFormat as shown below. The option simply does not exist.

 <TextBlock Text="{Binding Distance, StringFormat=\{0\}km}" />

Why is StringFormat not supported for Windows Phone 7?

+3
source share
2 answers

StringFormat has been added since 7.1 / Mango since Mango uses SL4. Example from Visual Studio Magazine :

<TextBlock Text="{Binding CurrentDate,StringFormat='dddd, d MMMM yyyy'}" />
+5
source

StringFormat is only available in SL4 and WPF versions ... and it is not available for WP7. This is Silverlight 3. You can use converters to format these bindings. Check out this link:

XAML Date Formatting on WP7

-2

Source: https://habr.com/ru/post/1782853/


All Articles