I want to display numbers i thousand separated format. Numbers are displayed in a Column of ListView control. I've the following xaml code, but it doesn't even compile!
<GridViewColumn Header="Total" DisplayMemberBinding="{Binding PaidValue, StringFormat={0:0,0}}" />
From my c# point of view, {0:0,0} is a correct format to do this, right? What is wrong with this?
The error is totally unrelated : "Unknown build error, 'Key Can not be null' pointing to the same line of xaml code. If tried other variants of the same format with no use.
OKay, I found a way to do this. I need to say that, in fact I DO have SP1 installed, so as a lot of blog posts are implying {0:c} should work, while it does not and will end up producing the same compile-time error! Here's how I did it:
<GridViewColumn DisplayMemberBinding="{Binding Path=PaidValue, StringFormat='0,0'}" />
Compiles and works with no problem. I wonder if other binding's StringFormat values are still valid.
<GridViewColumn Header="Total"
DisplayMemberBinding="{Binding PaidValue, StringFormat={0:c}}" />
Will format the number to the native string currency.
You can find more numeric formats from this site
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