I want to display a decimal with a Binding in a TextBlock.
The problem occurs when the decimal is 0. Nothing is displayed in the TextBox.
<TextBlock Text="{Binding Price, StringFormat={}{0:#,#.##}}"/>
This should do the trick:
{0:#,0.##}
Note: As @ASh pointed out:
Values between 0.0 and 1.0 will be displayed as 0.X instead of.X (eg 0.31 instead of.31)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.