Example #1
0
        private static void minValueChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DateTimeEditor DateTimeUpDown = ((DateTimeEditor)d);

            DateTimeUpDown.CoerceValue(DateTimeEditor.MaxValueProperty);
            DateTimeUpDown.CoerceValue(DateTimeEditor.ValueProperty);
        }
Example #2
0
        private static object coerceFormatCallback(DependencyObject d, object value)
        {
            DateTimeEditor DateTimeUpDown = ((DateTimeEditor)d);

            // check format is valid

            return(value);
        }
Example #3
0
        private static void valueChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DateTimeEditor           dt = (DateTimeEditor)d;
            DateTimeChangedEventArgs ea =
                new DateTimeChangedEventArgs(DateTimeEditor.ValueChangedEvent, d, (DateTime?)e.OldValue, (DateTime?)e.NewValue);

            dt.RaiseEvent(ea);
            //if (ea.Handled) DateTimeUpDown.Value = (DateTime)e.OldValue;
            //else
            if (e.NewValue == null)
            {
                dt.PART_TextBox.Text = string.Empty;
            }
            else
            {
                dt.PART_TextBox.Text = ((DateTime)e.NewValue).ToString(dt.Format);
            }
        }
Example #4
0
        private static object coerceValueCallback(DependencyObject d, object value)
        {
            DateTimeEditor dt = (DateTimeEditor)d;

            if (value != null)
            {
                DateTime val = (DateTime)value;
                if (val > dt.MinValue && val < dt.MaxValue)
                {
                    return(val);
                }
                else if (val < dt.MinValue)
                {
                    return(dt.MinValue);
                }
                else if (val < dt.MaxValue)
                {
                    return(dt.MaxValue);
                }
            }
            return(null);
        }