private static void OnItemHeightOrWidthPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { WrapPanel source = (WrapPanel)d; double value = (double)e.NewValue; // Ignore the change if requested if (source._ignorePropertyChange) { source._ignorePropertyChange = false; return; } // Validate the length (which must either be NaN or a positive, // finite number) if (!value.IsNaN() && ((value <= 0.0) || double.IsPositiveInfinity(value))) { // Reset the property to its original state before throwing source._ignorePropertyChange = true; source.SetValue(e.Property, (double)e.OldValue); string message = string.Format( CultureInfo.InvariantCulture, Properties.Resources.WrapPanel_OnItemHeightOrWidthPropertyChanged_InvalidValue, value); throw new ArgumentException(message, "value"); } // The length properties affect measuring. source.InvalidateMeasure(); }
private static void OnFlowDirectionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { WrapPanel source = (WrapPanel)d; FlowDirection value = (FlowDirection)e.NewValue; // Ignore the change if requested if (source._ignorePropertyChange) { source._ignorePropertyChange = false; return; } // Validate the Orientation if ((value != FlowDirection.LeftToRight) && (value != FlowDirection.RightToLeft)) { // Reset the property to its original state before throwing source._ignorePropertyChange = true; source.SetValue(OrientationProperty, (FlowDirection)e.OldValue); string message = string.Format( CultureInfo.InvariantCulture, // TODO: Add to the resources // WrapPanel_OnFlowDirectionPropertyChanged_InvalidValue Invalid FlowDirection value '{0}'. Exception thrown when the FlowDirection property is provided an invalid value. "Invalid FlowDirection value '{0}'.", value); throw new ArgumentException(message, "value"); } // Orientation affects measuring. source.InvalidateMeasure(); }
private static void OnOrientationPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { WrapPanel source = (WrapPanel)d; Orientation value = (Orientation)e.NewValue; // Ignore the change if requested if (source._ignorePropertyChange) { source._ignorePropertyChange = false; return; } // Validate the Orientation if ((value != Orientation.Horizontal) && (value != Orientation.Vertical)) { // Reset the property to its original state before throwing source._ignorePropertyChange = true; source.SetValue(OrientationProperty, (Orientation)e.OldValue); string message = string.Format( CultureInfo.InvariantCulture, Properties.Resources.WrapPanel_OnOrientationPropertyChanged_InvalidValue, value); throw new ArgumentException(message, "value"); } // Orientation affects measuring. source.InvalidateMeasure(); }
public static void SetNumberOfColumns(WrapPanel panel, int value) { panel.SetValue(NumberOfColumns, value); }