/// <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 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 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);
        }
        /// <summary>
        /// Get the parent FluidWrapPanel and check if the AssociatedObject is
        /// hosted inside a ListBoxItem (this scenario will occur if the FluidWrapPanel
        /// is the ItemsPanel for a ListBox).
        /// </summary>
        private void GetParentPanel()
        {
            FrameworkElement ancestor = this.AssociatedObject as FrameworkElement;

            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;
            }
        }