コード例 #1
0
        private static void minValueChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DateTimeUpDown DateTimeUpDown = ((DateTimeUpDown)d);

            DateTimeUpDown.CoerceValue(DateTimeUpDown.MaxValueProperty);
            DateTimeUpDown.CoerceValue(DateTimeUpDown.ValueProperty);
        }
コード例 #2
0
        private static object coerceFormatCallback(DependencyObject d, object value)
        {
            DateTimeUpDown DateTimeUpDown = ((DateTimeUpDown)d);

            // check format is valid

            return(value);
        }
コード例 #3
0
        private static void valueChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DateTimeUpDown        dt = (DateTimeUpDown)d;
            ValueChangedEventArgs ea =
                new ValueChangedEventArgs(DateTimeUpDown.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);
            }
        }
コード例 #4
0
        private static object coerceValueCallback(DependencyObject d, object value)
        {
            DateTimeUpDown dt = (DateTimeUpDown)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);
        }