public DateTime?GetDateAsDateTime()
        {
            var str = Date as string;

            if (str != null)
            {
                var      formatted = DateControl.DateToStr(str);
                DateTime dt;
                if (DateTime.TryParse(formatted, out dt))
                {
                    return(dt);
                }
                else
                {
                    int year;
                    if (Int32.TryParse(formatted, out year))
                    {
                        if (year > 0 && year <= 9999)
                        {
                            var tempDate = "01 jan " + formatted;
                            if (DateTime.TryParse(tempDate, out dt))
                            {
                                return(dt);
                            }
                        }
                    }
                }
            }
            return(null);
        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var str = value as string;

            if (str != null)
            {
                var      formatted = DateControl.DateToStr(str);
                DateTime dt;
                if (DateTime.TryParse(formatted, out dt))
                {
                    return(dt);
                }
                else
                {
                    int year;
                    if (Int32.TryParse(formatted, out year))
                    {
                        if (year > 0 && year <= 9999)
                        {
                            var tempDate = "01 jan " + formatted;
                            if (DateTime.TryParse(tempDate, out dt))
                            {
                                return(dt);
                            }
                        }
                    }
                }
            }
            return(null);
        }
        private static void OnDateChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            var control = obj as DateControl;

            control.lblDebug.Content = control.Date;
            if (!control._selfSet)
            {
                control.txt.Text = DateControl.DateToStr(control.Date);
            }
        }