Exemplo n.º 1
0
        /// <summary>
        /// StretchProperty property changed handler.
        /// </summary>
        /// <param name="d">Viewbox that changed its Stretch.</param>
        /// <param name="e">Event arguments.</param>
        private static void OnStretchPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Viewbox vb = (Viewbox)d;

            if (!IsValidStretchValue(e.NewValue))
            {
                // revert the change
                vb.Stretch = (Stretch)e.OldValue;
                throw new ArgumentException();
            }

            // The Stretch property affects measuring
            vb.InvalidateMeasure();
        }
Exemplo n.º 2
0
        /// <summary>
        /// StretchDirectionProperty property changed handler.
        /// </summary>
        /// <param name="d">Viewbox that changed its StretchDirection.</param>
        /// <param name="e">Event arguments.</param>
        private static void OnStretchDirectionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Viewbox vb = (Viewbox)d;

            if (!IsValidStretchDirectionValue(e.NewValue))
            {
                // revert the change
                vb.StretchDirection = (StretchDirection)e.OldValue;

                // throw exception
                string message = string.Format(
                    CultureInfo.InvariantCulture,
                    Properties.Resources.Viewbox_OnStretchDirectionPropertyChanged_InvalidValue,
                    e.NewValue);
                throw new ArgumentException(message, "e");
            }

            // The StretchDirection property affects measuring
            vb.InvalidateMeasure();
        }