/// <summary>
        /// Subscribes an element to the private managers.
        /// </summary>
        /// <param name="target">The framework element.</param>
        private static void SubscribeFrameworkElement(FrameworkElement target)
        {
            if (!TurnstileFeatherEffect.GetIsSubscribed(target))
            {
                // Find the parent page.
                PhoneApplicationPage page = TemplatedVisualTreeExtensions.GetParentByType <PhoneApplicationPage>(target);

                if (page == null)
                {
                    return;
                }

                TurnstileFeatherEffect.SetParentPage(target, page);
                TurnstileFeatherEffect.SetIsSubscribed(target, true);
            }
        }
        /// <summary>
        /// Returns the set of weak references to the items
        /// that must be animated.
        /// </summary>
        /// <returns>
        /// A set of weak references to items sorted by their feathering index.
        /// </returns>
        private static IList <WeakReference> GetTargetsToAnimate()
        {
            List <WeakReference>  references;
            List <WeakReference>  targets = new List <WeakReference>();
            PhoneApplicationPage  page    = null;
            PhoneApplicationFrame frame   = Application.Current.RootVisual as PhoneApplicationFrame;

            if (frame != null)
            {
                page = frame.Content as PhoneApplicationPage;
            }

            if (page == null)
            {
                return(null);
            }

            if (!_pagesToReferences.TryGetValue(page, out references))
            {
                return(null);
            }

            foreach (WeakReference r in references)
            {
                FrameworkElement target = r.Target as FrameworkElement;

                // If target is null, skip.
                if (target == null)
                {
                    continue;
                }

                // If target is not on the screen, skip.
                if (!IsOnScreen(target))
                {
                    continue;
                }

                ListBox          listBox          = r.Target as ListBox;
                LongListSelector longListSelector = r.Target as LongListSelector;
                Pivot            pivot            = r.Target as Pivot;

                if (listBox != null)
                {
                    // If the target is a ListBox, feather its items individually.
                    ItemsControlExtensions.GetItemsInViewPort(listBox, targets);
                }
                else if (longListSelector != null)
                {
#if WP7
                    // If the target is a LongListSelector, feather its items individually.
                    ListBox child = TemplatedVisualTreeExtensions.GetFirstLogicalChildByType <ListBox>(longListSelector, false);

                    if (child != null)
                    {
                        ItemsControlExtensions.GetItemsInViewPort(child, targets);
                    }
#else
                    LongListSelectorExtensions.GetItemsInViewPort(longListSelector, targets);
#endif
                }
                else if (pivot != null)
                {
                    // If the target is a Pivot, feather the title and the headers individually.
                    ContentPresenter title = TemplatedVisualTreeExtensions.GetFirstLogicalChildByType <ContentPresenter>(pivot, false);

                    if (title != null)
                    {
                        targets.Add(new WeakReference(title));
                    }

                    PivotHeadersControl headers = TemplatedVisualTreeExtensions.GetFirstLogicalChildByType <PivotHeadersControl>(pivot, false);

                    if (headers != null)
                    {
                        targets.Add(new WeakReference(headers));
                    }
                }
                else
                {
                    // Else, feather the target as a whole.
                    targets.Add(r);
                }
            }

            return(targets);
        }