Is there any way to format the values that are bound to a datagrid? For example I have the following:
<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>
I’d like the Date column to be just date (not time) and the Amount column to be currency format. Here’s how I populate the datagrid:
var transactions = TransactionManager.GetTransactions();
dgTransactionLog.ItemsSource = transactions;
Use the
StringFormatproperty: