I thought this would be rather simple and probably is but I cannot find anything on google. I have a WPF application with a datagrid bound to my object which contains properties of type bool, string & int. Where int is displayed I want to show 30,000 rather than 30000. How is this acheieve?
Any help would be great, Thanks, M
You're looking for StringFormat
<DataGridTextColumn Binding="{Binding myInt, StringFormat=\{0:N0\}}"/>
or
<DataGridTextColumn Binding="{Binding myInt, StringFormat={}{0:N0}}"/>
If you use a DataGridTextColumn you can use a StringFormatter on your binding
<DataGrid>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding MyNumber, StringFormat={0:#,0} {1:#,0}}" />
</DataGrid.Columns>
</DataGrid>
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