<DataGrid....
<DataGrid.Resources>
<DataTemplate DataType="{x:Type DateTime}">
<TextBlock Text="{Binding StringFormat={}{0:d}}" />
</DataTemplate>
</DataGrid.Resources>
...
<DataGridTemplateColumn Header="Время оплаты">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock VerticalAlignment="Center" Text="{Binding date_payment}" Width="Auto" Height="Auto" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
但是此列具有类型DateTime
...我需要在此类型(字符串)上转换此列,因为我需要在此列上重命名值行,LoadingRow
所以我使用事件
DataRowView item = e.Row.Item as DataRowView;
DataRow row = item.Row;
var time = row[4];
if (Convert.ToString(time) == "01.01.0001 0:00:00")
{
row[4] = "No payment";
}
但它错了,行没有转换为字符串,请帮忙