/// <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. listBox.GetItemsInViewPort(targets); } else if (longListSelector != null) { #if WP7 // If the target is a LongListSelector, feather its items individually. ListBox child = longListSelector.GetFirstLogicalChildByType <ListBox>(false); if (child != null) { child.GetItemsInViewPort(targets); } #else longListSelector.GetItemsInViewPort(targets); #endif } else if (pivot != null) { // If the target is a Pivot, feather the title and the headers individually. ContentPresenter title = pivot.GetFirstLogicalChildByType <ContentPresenter>(false); if (title != null) { targets.Add(new WeakReference(title)); } PivotHeadersControl headers = pivot.GetFirstLogicalChildByType <PivotHeadersControl>(false); if (headers != null) { targets.Add(new WeakReference(headers)); } } else { // Else, feather the target as a whole. targets.Add(r); } } return(targets); }