Applying String.Format on Numeric values

I was trying to apply String.Format on a textbox which was bound to double. The normal string.format functionality is that it will only work for strings, so i added a converter, still the value was not showing correctly formatted on the screen.

I was trying to show a “%” sign next to the value since it was a percentage information. Finally figured out that the correct escape sequence was missing hence the string.format was failing.

<TextBlock Text=”{Binding ElementName=BacktestAccuracySlider, Path=Value, Converter={StaticResource DoubleToStringConverter}, StringFormat=\{0\}%,FallbackValue=XX}”/>

That is the correct way to escape the fiddly StringFormat syntax.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s