【发布时间】:2018-09-10 14:45:41
【问题描述】:
我正在尝试格式化 datagrid 数据单元格中的数字,以使 '1000000.52' 看起来像:'1 000 000.52'。
我试图寻找启用此类功能的属性,但只能在 DataGridCell 类中找到 ContentStringFormat 属性。不幸的是,我尝试的方法不起作用:
<DataGrid CanUserAddRows="False" Name="EGrid" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" ItemsSource="{Binding Path=Data, Mode=TwoWay, ElementName=ExportableGrid}">
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="ContentStringFormat" Value="## ### ###.00"/>
</Style>
</DataGrid.CellStyle>
</DataGrid>
我怎样才能做到这一点?任何帮助将不胜感激,在此先感谢。
【问题讨论】:
-
我认为解决这个问题的正确方法是将您的双精度转换为字符串,然后对其进行处理以实现您所需要的。