/// <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 viewBox = (Viewbox)d; if (e.NewValue != e.OldValue) { // The StretchDirection property affects measuring viewBox.InvalidateMeasure(); } }
/// <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 new ArgumentException("StretchDirection"); } // The StretchDirection property affects measuring vb.InvalidateMeasure(); }