xaml Data Binding Formatting String Bindings


When making a bind of something, for example a date you may want to show it in a specific format without messing around with it in the code.

To do this we can use the StringFormat property.

Here are some examples:

Text="{Binding Path=ReleaseDate, StringFormat=dddd dd MMMM yyyy}"

This formats my date to the following:

Tuesday 16 August 2016

Here is another example for temperature.

Text="{Binding Path=Temp, StringFormat={}{0}°C}"

This formats to: