WPF Datagrid Column Format Number to include commas

后端 未结 2 838
逝去的感伤
逝去的感伤 2020-12-18 22:27

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 proper

相关标签:
2条回答
  • 2020-12-18 23:03

    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>
    
    0 讨论(0)
  • 2020-12-18 23:23

    You're looking for StringFormat

    <DataGridTextColumn Binding="{Binding myInt, StringFormat=\{0:N0\}}"/>
    

    or

    <DataGridTextColumn Binding="{Binding myInt, StringFormat={}{0:N0}}"/>
    
    0 讨论(0)
提交回复
热议问题