'How to Format float value from 11111111 to 1,111,111.00?

I've been all over the Internet, and since I have no much experience, I couldn't find a right solution.

As mentioned above, in my database I will have "big" values, where there are up to 9-10 digits, and I was requested to format them like, for example, instead of 23456789 -> 23,456,789.00, and show them like that in DataGrid.

This is how i populate DataGrid

probaDataContext proba = new probaDataContext();
        public MainWindow()
            {
                InitializeComponent();
    
                dgData.ItemsSource = proba.ProbaTabelas.ToList();
    }

And this is my XAML code

I found a way how to Format them to 23,456,789 , but I still need those two digits behind, with the dot.

<DataGrid Name="dgData" Margin="89,0,118,165" AutoGenerateColumns="False">
        <DataGrid.Columns>
            <DataGridTextColumn Header="Numbernumber" Binding="{Binding cifra, StringFormat=\{0:N0\}}"></DataGridTextColumn>
        </DataGrid.Columns>
    </DataGrid

If the value is a whole number, they should be .00 , if a value has decimals like 23432.54, they should look like 23,432.54.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source