Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
506
XamDateTimeEditor
posted

Hi,

I've a XamDateTimeEditor binded to a string property that contains the date.

When the DataContext is loaded, if the property is empty (""), the field display 01/01/0001.

I want an empty field.

How can I set this behavior

Thks.

 

Sacha

Parents
No Data
Reply
  • 27093
    posted

    Hello,

     

    I have been looking into this for you and did replicate the behavior you described.  This can be overcome by creating a converter of your own and setting it to the XamDateTimeEditor’s ValueToDisplayTextConverter property. I did some more research and was able to create a converter for you to achieve your goal:

     

        public class DTtoString : IValueConverter

        {

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

            {

                if (value != null)

                {

                    DateTime temp = new DateTime();

                    if (DateTime.TryParse(value.ToString(), out temp))

                    {

                        if (temp == (parameter as XamDateTimeEditor).ComputedMinDate)

                        {

                            return null;

                        }

     

                        return temp.ToString(culture);

     

                    }

                    return null;

                }

                else return null;     

            }

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

            {

                return value;

            }

        }

     

     

    Please let me know if I can assist you further on the matter.

     

    Sincerely,

    Petar Monov

    Developer Support Engineer

    Infragistics Bulgaria

    www.infragistics.com/support

Children
No Data