Beispiel #1
0
        private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RadNumericBox numericBox = d as RadNumericBox;

            if (numericBox == null || numericBox.IsInternalPropertyChange)
            {
                return;
            }

            numericBox.updatingValue = true;

            double?oldValue       = numericBox.valueCache;
            double?newDoubleValue = null;

            if (e.NewValue != null)
            {
                double doubleValue;
                if (!NumericConverter.TryConvertToDouble(e.NewValue, out doubleValue))
                {
                    throw new ArgumentException("The object of type " + e.NewValue.GetType() + " may not be converted to a numerical value.");
                }

                RangeControlBase.VerifyValidDoubleValue(doubleValue);
                newDoubleValue = doubleValue;
            }

            if (numericBox.IsTemplateApplied)
            {
                var coercedValue = numericBox.CoerceValue(newDoubleValue);
                if (coercedValue.HasValue)
                {
                    newDoubleValue = coercedValue.Value;
                }
            }

            numericBox.valueCache = newDoubleValue;

            numericBox.updatingValue = false;

            if (oldValue != numericBox.Value)
            {
                if (numericBox.TextBox != null && numericBox.TextBox.FocusState == FocusState.Unfocused)
                {
                    numericBox.UpdateTextBoxText();
                }

                numericBox.OnValueChanged();
            }

            RadNumericBoxAutomationPeer peer = FrameworkElementAutomationPeer.FromElement(numericBox) as RadNumericBoxAutomationPeer;

            if (peer != null && oldValue != null && newDoubleValue != null)
            {
                peer.RaiseValuePropertyChangedEvent(oldValue, newDoubleValue);
            }
        }
Beispiel #2
0
        internal override void OnMinimumChanged(double oldMinimum, double newMinimum)
        {
            base.OnMinimumChanged(oldMinimum, newMinimum);

            this.CoerceValue(this.Value);

            RadNumericBoxAutomationPeer peer = FrameworkElementAutomationPeer.FromElement(this) as RadNumericBoxAutomationPeer;

            if (peer != null)
            {
                peer.RaiseMaximumPropertyChangedEvent((double)oldMinimum, (double)newMinimum);
            }
        }