// private void WaitForSpecializedContent() // { ////#if DEBUG_LOADING_PIVOT_ITEM // //Debug.WriteLine(" ... but the data isn't ready yet."); ////#endif // if (!_contentPresenterUnloaded) // { // if (_advancedWaitingElement.IsLoadComplete) // { // DelayedDispatcherTimer.BeginInvoke(AdditionalLoadTime, FinallyShowContent); // } // else // { // DelayedDispatcherTimer.BeginInvoke(SmartLoadingDelayingTime, WaitForSpecializedContent); // } // } // } private void TryTransitionToContent() { if (_contentPresenterUnloaded) { return; } //#if DEBUG_LOADING_PIVOT_ITEM //Debug.WriteLine("LPI: DataContext of {0} is set to {1}", Header.ToString(), DataContext.ToString()); //#endif // Visuals first to grab any control. var descendantsOnce = _contentPresenter.GetVisualDescendants().ToList(); _pauseAndResumeChild = descendantsOnce.OfType <ISupportPauseResume>().FirstOrDefault(); //_advancedWaitingElement = descendantsOnce.OfType<ISendLoadComplete>().FirstOrDefault(); _dataStatusElement = descendantsOnce.OfType <ISendLoadStatus>().FirstOrDefault(); // If the bindings never get applied due to visibility converters. //var uie = _advancedWaitingElement as UIElement; var uie = _dataStatusElement as UIElement; if (uie != null && uie.Visibility == Visibility.Collapsed) { _dataStatusElement = null; //_advancedWaitingElement = null; } if (_dataStatusElement /*_advancedWaitingElement */ == null) { // Pause and resume is not support for these two. var fe = descendantsOnce.OfType <ItemsControl>().Where(it => it.ItemsSource is ISendLoadStatus). FirstOrDefault(); if (fe != null) { _dataStatusElement = (ISendLoadStatus)fe.ItemsSource; //_advancedWaitingElement = (ISendLoadComplete) fe.ItemsSource; } if (_dataStatusElement /*_advancedWaitingElement */ == null) { var de = descendantsOnce.OfType <FrameworkElement>().Where(ff => ff.DataContext is ISendLoadStatus) .FirstOrDefault(); if (de != null) { _dataStatusElement = de.DataContext as ISendLoadStatus; // _advancedWaitingElement = de.DataContext as ISendLoadComplete; } } } if (_dataStatusElement /*_advancedWaitingElement */ != null) { #if DEBUG_LOADING_PIVOT_ITEM Debug.WriteLine("LPI: Custom item base {0} supports load notifications. Excellent.", _dataStatusElement.GetType().ToString()); #endif // if (_advancedWaitingElement.IsLoadComplete) if (_dataStatusElement.LoadStatus == LoadStatus.Loaded || _dataStatusElement.LoadStatus == LoadStatus.Failed) { OnceSpecializedContentIsReady(); } else { _dataStatusElement.LoadStatusChanged += OnAdvancedWaitingElementLoadComplete; //_advancedWaitingElement.LoadComplete += OnAdvancedWaitingElementLoadComplete; //return; } // don't let it appear by accident... return; } Debug.Assert(!_contentPresenterUnloaded); DelayedDispatcherTimer.BeginInvoke(AdditionalLoadTime, FinallyShowContent); }