Original User: ali5110Sanjay, If you need to use converters to show DateTime data types in your GraphicsLayer,1. In your code, implement your date converter. A simple converter could be something like the following:
public class DateConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return System.Convert.ToDateTime(value, System.Globalization.CultureInfo.CurrentCulture).ToShortDateString();
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return System.Convert.ToDateTime(value, System.Globalization.CultureInfo.CurrentCulture);
}
}
2. Define a XML namespace referencing your converter namespace. In this sample I have developed my converter in the same namespace:
xmlns:local="clr-namespace:MySilverlightApplication"
3. Add your converter to your resources:
<local:DateConverter x:Key="DateConverter" />
4. Set FeatureDataGrid AutoGenerateColumns property to FALSE and manually define its columns collection. In this example my GraphicsLayer has STRING_ATTRIBUTE and DATE_ATTRIBUTE attributes where the latter requires conversion for both showing and editing its contents (convert back):
<esri:FeatureDataGrid x:Name="MyDataGrid" AutoGenerateColumns="False" Map="{Binding ElementName=MyMap}" GraphicsLayer="{Binding Layers[MyGraphicsLayer], ElementName=MyMap}">
<esri:FeatureDataGrid.Columns>
<data:DataGridTextColumn Binding="{Binding STRING_ATTRIBUTE}" Header="String Attribute" />
<data:DataGridTextColumn Binding="{Binding DATE_ATTRIBUTE, Converter={StaticResource DateConverter}}" Header="Date Attribute" />
</esri:FeatureDataGrid.Columns>
</esri:FeatureDataGrid>
Where "data" refers to:
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
Hope this helps.