1

For example, I have data grid in Source Control GUI in Visual Studio: enter image description here

Pay attention for formating of string in column "Size". This number is 8100 bytes, and it was separated by dots (instead of comma) and one zero was trimmed. Maybe they did it through converters, but I believe they used sophisticated string format. I found a lot of suggestion how to separate thousands, but solution that were offered aren't working in reguired way and trimming of zeros I haven't found at all. Does someone know how to implement number format like in the screenshot? I think it should be something like that:

 <DataGridTextColumn Header="Size"
                                Width="*"
                                Binding="{Binding Size, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, StringFormat='{}{0:#,#} KB',ConverterCulture=de}" />
Mr.B
  • 3,484
  • 2
  • 26
  • 40
  • Possible duplicate of [How do I get a human-readable file size in bytes abbreviation using .NET?](http://stackoverflow.com/questions/281640/how-do-i-get-a-human-readable-file-size-in-bytes-abbreviation-using-net) – mattmanser Jul 13 '16 at 08:47
  • 2
    The question was about how to do that with string format without using code behind like converter or something like that. – Mr.B Jul 13 '16 at 08:55
  • That's not how string format works, string format is not being used to create those values, your belief is wrong. This question has been asked hundreds of times and the answer is always the same. For XAML, usually what you'd do is make a property on your view model called some like `DisplaySize` and have the formatting code in the linked dupe question there. A string format is used for simple scenarios. – mattmanser Jul 13 '16 at 09:33
  • Have you read this https://msdn.microsoft.com/en-us/library/0c899ak8%28v=VS.100%29.aspx?f=255&MSPPError=-2147217396 – Athafoud Jul 13 '16 at 09:46
  • The given XAML example shows format code almost in the way I need. Maybe it is possible only with converters. – Mr.B Jul 13 '16 at 09:52

0 Answers0