Hi,
I am binding my Datagrid to a dataset which have a DateTime column where the strings have the format "dd/mm/yyyy hh:mm:ss ". I would like to format the cells to display the Date part only. I have tried using the DataType property
DataType="System.DateTime"
But get an error message saying can not find type DateTime.
I would prefer to not manipulate the dataset, would appreciate if someone could advice if it is possible to format the cells to display the date only
ThanksNiclas
I use the XamDateTimeEditor's mask. Or you could use a Converter but that requires code behind. If your original data is a DateTime type then XamDataGrid uses a XamDateTimeEditor automatically.
<igData:Field Name="Date" Label="Date"> <igData:Field.Settings> <igData:FieldSettings CellWidth="120" LabelWidth="120"> <igData:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamDateTimeEditor}" > <Style.Setters> <Setter Property="Mask" Value="{}{date}"/> </Style.Setters> </Style> </igData:FieldSettings.EditorStyle> </igData:FieldSettings> </igData:Field.Settings></igData:Field>
I havent got access to XamDateTimeEditor, if you have a small sampl,e for how to use a convert it would be appreciated
Thanks
Niclas
In code behind:
public class DateConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
DateTime val = (DateTime)value;
if (val == DateTime.MinValue)
return null;
else
return val.Date;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
return value;
In XAML (where local is a reference to the namespace containing your above converter):
</Window.Resources>
<local:DateConverter x:Key="dateConv"/>
...
<igDP:Field Name="Date" Label="Date" Converter="{StaticResource dateConv}"/>