/// <summary> /// Get the parent OldFluidWrapPanel and check if the AssociatedObject is /// hosted inside a ListBoxItem (this scenario will occur if the OldFluidWrapPanel /// is the ItemsPanel for a ListBox). /// </summary> private void GetParentPanel() { if ((AssociatedObject as FrameworkElement) == null) { return; } var ancestor = (FrameworkElement)AssociatedObject; while (ancestor != null) { if (ancestor is ListBoxItem) { _parentLbItem = ancestor as ListBoxItem; } if (ancestor is FluidWrapPanel) { _parentFwPanel = ancestor as FluidWrapPanel; // No need to go further up return; } // Find the visual ancestor of the current item ancestor = VisualTreeHelper.GetParent(ancestor) as FrameworkElement; } }
/// <summary> /// Handles changes to the DragEasing property. /// </summary> /// <param name="d">FluidWrapPanel</param> /// <param name="e">DependencyProperty changed event arguments</param> private static void OnDragEasingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FluidWrapPanel panel = (FluidWrapPanel)d; EasingFunctionBase oldDragEasing = (EasingFunctionBase)e.OldValue; EasingFunctionBase newDragEasing = panel.DragEasing; panel.OnDragEasingChanged(oldDragEasing, newDragEasing); }
/// <summary> /// Handles changes to the Orientation property. /// </summary> /// <param name="d">FluidWrapPanel</param> /// <param name="e">DependencyProperty changed event arguments</param> private static void OnOrientationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FluidWrapPanel panel = (FluidWrapPanel)d; Orientation oldOrientation = (Orientation)e.OldValue; Orientation newOrientation = panel.Orientation; panel.OnOrientationChanged(oldOrientation, newOrientation); }
/// <summary> /// Handles changes to the ItemsSource property. /// </summary> /// <param name="d">FluidWrapPanel</param> /// <param name="e">DependencyProperty changed event arguments</param> private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FluidWrapPanel panel = (FluidWrapPanel)d; IEnumerable oldItemsSource = (ObservableCollection <UIElement>)e.OldValue; IEnumerable newItemsSource = panel.ItemsSource; panel.OnItemsSourceChanged(oldItemsSource, newItemsSource); }
/// <summary> /// Handles changes to the ItemWidth property. /// </summary> /// <param name="d">FluidWrapPanel</param> /// <param name="e">DependencyProperty changed event arguments</param> private static void OnItemWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FluidWrapPanel fwPanel = (FluidWrapPanel)d; double oldItemWidth = (double)e.OldValue; double newItemWidth = fwPanel.ItemWidth; fwPanel.OnItemWidthChanged(oldItemWidth, newItemWidth); }
/// <summary> /// Handles changes to the IsComposing property. /// </summary> /// <param name="d">FluidWrapPanel</param> /// <param name="e">DependencyProperty changed event arguments</param> private static void OnIsComposingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FluidWrapPanel panel = (FluidWrapPanel)d; bool oldIsComposing = (bool)e.OldValue; bool newIsComposing = panel.IsComposing; panel.OnIsComposingChanged(oldIsComposing, newIsComposing); }
/// <summary> /// Handles changes to the DragScale property. /// </summary> /// <param name="d">FluidWrapPanel</param> /// <param name="e">DependencyProperty changed event arguments</param> private static void OnDragScaleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FluidWrapPanel panel = (FluidWrapPanel)d; double oldDragScale = (double)e.OldValue; double newDragScale = panel.DragScale; panel.OnDragScaleChanged(oldDragScale, newDragScale); }