I have a value converter that formats numbers (I can't use SP1 yet unfortunately). It works fine until it gets a percentage.
Here's an example:
<TextBlock Text="{Binding Path=PercentageComplete,
Converter={StaticResource NumberFormatter},
ConverterParameter='0.00 %'}" />
Unfortunately for me when Double.ToString
sees a percentage character, it multiplies the number by 100. In my case, the number is already a percentage and no conversion is needed.
In C#, this would be achieved by escaping the %
character with a single quote:
(99.99).ToString("0.00 %") // gives -> "9999 %"
(99.99).ToString("0.00 '%") // gives -> "99.99 %"
Unfortunately, I cannot use a single quote in the ConverterParameter
in the above XAML markup extension. Is there a way of escaping it? I have tried doubling the single quotes and using a backslash, but both failed to compile.
ConverterParameter='0.00 "%'
. Many thanks. – Reverso