有没有办法对绑定到datagrid中的值进行格式化?例如,我有以下内容:
<DataGrid AutoGenerateColumns="False" Height="487" HorizontalAlignment="Left" Margin="12,12,0,0" Name="dgTransactionLog" VerticalAlignment="Top" Width="404">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Path=Date}" Header="Date" />
<DataGridTextColumn Binding="{Binding Path=Payee1.Name}" Header="To/From" />
<DataGridTextColumn Binding="{Binding Path=Amount}" Header="Amount" />
</DataGrid.Columns>
</DataGrid>
我希望Date列只显示日期(不显示时间),Amount列以货币格式显示。以下是我如何填充datagrid的代码:
var transactions = TransactionManager.GetTransactions();
dgTransactionLog.ItemsSource = transactions;