views:

996

answers:

2

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.

+2  A: 
<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

Tawani
this, also, does not compile! same error as above! I checked and I actually HAVE installed SP1
Hadi Eskandari
+2  A: 

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.

Hadi Eskandari