Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

  • codebased

    codebased

    Participant

    826 Points

    386 Posts

    Re: Formating Data grid date column

    Apr 23, 2008 11:55 PM | LINK

    I've created a class called Converter1 and i am using the way it has been suggested. However, it is not working at all.

    public class Converter1 : IValueConverter

    {

    #region IValueConverter Members

    //Define the Convert method to change DateTime object to string

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

    {

    //value is the data from the source object

    DateTime thisdate = (DateTime)value;

    return thisdate.ToString("d");

    }

    //ConvertBack not implemented for OneWay binding

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

    {

    throw new NotImplementedException();

    }

    #endregion

    }

     

     

    <TextBlock Padding="5,0,5,0" Text="{Binding DateOfBirth, Converter={StaticResource Converter1}}" />

    "If I've answered your query then please mark it as "Answered".