private void OnceSpecializedContentIsReady() { Debug.WriteLine("OnceSpecializedContentIsReady!"); if (_dataStatusElement != null && _dataStatusElement.LoadStatus == LoadStatus.Failed) { Debug.WriteLine("FAILED that is..."); LoadingText = "FAILED!!!!!!"; bool mayHaveHadDataAlready = false; ISendLoadComplete islc = _dataStatusElement as ISendLoadComplete; if (islc != null) { if (islc.IsLoadComplete) { mayHaveHadDataAlready = true; // There "was" data and now there's been an error... } } if (!mayHaveHadDataAlready) { RestoreLoadingGrid(); } // NOTE: Never will call FinallyShowContent. return; } DelayedDispatcherTimer.BeginInvoke(AdditionalLoadTime, FinallyShowContent); }
// 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(); // If the bindings never get applied due to visibility converters. var uie = _advancedWaitingElement as UIElement; if (uie != null && uie.Visibility == Visibility.Collapsed) { _advancedWaitingElement = null; } if (_advancedWaitingElement == null) { // Pause and resume is not support for these two. var fe = descendantsOnce.OfType <ItemsControl>().Where(it => it.ItemsSource is ISendLoadComplete). FirstOrDefault(); if (fe != null) { _advancedWaitingElement = (ISendLoadComplete)fe.ItemsSource; } if (_advancedWaitingElement == null) { var de = descendantsOnce.OfType <FrameworkElement>().Where(ff => ff.DataContext is ISendLoadComplete) .FirstOrDefault(); if (de != null) { _advancedWaitingElement = de.DataContext as ISendLoadComplete; } } } if (_advancedWaitingElement != null) { #if DEBUG_LOADING_PIVOT_ITEM Debug.WriteLine("LPI: Custom item base {0} supports load notifications. Excellent.", _advancedWaitingElement.GetType().ToString()); #endif if (_advancedWaitingElement.IsLoadComplete) { OnceSpecializedContentIsReady(); } else { _advancedWaitingElement.LoadComplete += OnAdvancedWaitingElementLoadComplete; } return; } Debug.Assert(!_contentPresenterUnloaded); DelayedDispatcherTimer.BeginInvoke(AdditionalLoadTime, FinallyShowContent); }
// 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(); // If the bindings never get applied due to visibility converters. var uie = _advancedWaitingElement as UIElement; if (uie != null && uie.Visibility == Visibility.Collapsed) { _advancedWaitingElement = null; } if (_advancedWaitingElement == null) { // Pause and resume is not support for these two. var fe = descendantsOnce.OfType<ItemsControl>().Where(it => it.ItemsSource is ISendLoadComplete). FirstOrDefault(); if (fe != null) { _advancedWaitingElement = (ISendLoadComplete)fe.ItemsSource; } if (_advancedWaitingElement == null) { var de = descendantsOnce.OfType<FrameworkElement>().Where(ff => ff.DataContext is ISendLoadComplete) .FirstOrDefault(); if (de != null) { _advancedWaitingElement = de.DataContext as ISendLoadComplete; } } } if (_advancedWaitingElement != null) { #if DEBUG_LOADING_PIVOT_ITEM Debug.WriteLine("LPI: Custom item base {0} supports load notifications. Excellent.", _advancedWaitingElement.GetType().ToString()); #endif if (_advancedWaitingElement.IsLoadComplete) OnceSpecializedContentIsReady(); else _advancedWaitingElement.LoadComplete += OnAdvancedWaitingElementLoadComplete; return; } Debug.Assert(!_contentPresenterUnloaded); DelayedDispatcherTimer.BeginInvoke(AdditionalLoadTime, FinallyShowContent); }