How can I format a decimal value conditionally in a WPF window?
Currently I use bellow mark up to format the decimal value, but it displays 00 when the value is 0.00. Please help.
<TextBlock
Grid.Column="6"
Padding="2"
Text="{Binding Path=TotalAwardsExpended, StringFormat='{}{0:0,0}'}" />
The extra 0 comes from the 0 after the colon.
Instead, try {}{0:#,0}
.
From the MSDN docs on Custom Numeric String formats (emphasis added):
"0" | Zero placeholder | Replaces the zero with the corresponding digit if one is present; otherwise, zero appears in the result string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With