WPF ListView Thousand Separator

I want to display numbers in thousands of separated formats. The numbers are displayed in the column of the ListView control. I have 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 the correct format to do this, right? What's wrong with that?

The error is completely unrelated: "Unknown build error," Key cannot be empty "pointing to the same line of xaml code If you have tried other variations of the same format without using.

+1


a source to share


2 answers


Ok I found a way to do this. I have to say that I actually have SP1 installed as many blog posts imply that {0: c} should work, which it doesn't and will result in the same compile time error! This is how I did it:


<GridViewColumn DisplayMemberBinding="{Binding Path=PaidValue, StringFormat='0,0'}" />

      



Will compile and run without issue. I wonder if there are still StringFormat binding values ​​left.

+6


a source


<GridViewColumn Header="Total" 
DisplayMemberBinding="{Binding PaidValue, StringFormat={0:c}}" />

      

Will format the number in national currency.



You can find more number formats from this site

+2


a source







All Articles