Beispiel #1
0
        /// <summary>
        /// Handler for the ScrollViewer's DirectManipulationCompleted event.
        /// Raises the RefreshRequested event and executes the RefreshCommand
        /// command when a refresh was activated during the manipulation.
        /// </summary>
        private void Scroller_DirectManipulationCompleted(object sender, object e)
        {
            System.Diagnostics.Debug.Assert(
                m_root != null &&
                m_scroller != null &&
                m_scrollerContent != null &&
                m_refreshIndicatorContainer != null);

            Windows.UI.Xaml.Media.CompositionTarget.Rendering -= CompositionTarget_Rendering;
            m_scroller.ViewChanging -= Scroller_ViewChanging;

            if (m_refreshActivated)
            {
                if (this.RefreshRequested != null)
                {
                    RefreshRequestedEventArgs refreshRequestedEventArgs = new RefreshRequestedEventArgs(
                        this.AutoRefresh ? new DeferralCompletedHandler(RefreshCompleted) : null);
                    this.RefreshRequested(this, refreshRequestedEventArgs);
                    if (this.AutoRefresh)
                    {
                        m_scrollerContent.ManipulationMode = ManipulationModes.None;
                        if (!refreshRequestedEventArgs.WasDeferralRetrieved)
                        {
                            // The Deferral object was not retrieved in the event handler.
                            // Animate the content up right away.
                            this.RefreshCompleted();
                        }
                    }
                }

                if (this.RefreshCommand != null && this.RefreshCommand.CanExecute(null))
                {
                    this.RefreshCommand.Execute(null);
                }
            }

            m_isAutoRefreshing      = false;
            m_refreshActivated      = false;
            m_lastRefreshActivation = default(DateTime);

            this.UpdateCompositionAnimations();
            if (m_scrollerContent.ManipulationMode == ManipulationModes.System)
            {
                this.UpdateRefreshableStatus(m_scroller.VerticalOffset < INITIAL_VERTICALOFFSET_THRESHOLD /*refreshActivatable*/, m_scroller.VerticalOffset < INITIAL_VERTICALOFFSET_THRESHOLD /*force*/);
            }
        }
        /// <summary>
        /// Handler for the ScrollViewer's DirectManipulationCompleted event.
        /// Raises the RefreshRequested event and executes the RefreshCommand
        /// command when a refresh was activated during the manipulation.
        /// </summary>
        private void Scroller_DirectManipulationCompleted(object sender, object e)
        {
            System.Diagnostics.Debug.Assert(
                m_root != null &&
                m_scroller != null &&
                m_scrollerContent != null &&
                m_refreshIndicatorContainer != null);

            Windows.UI.Xaml.Media.CompositionTarget.Rendering -= CompositionTarget_Rendering;
            m_scroller.ViewChanging -= Scroller_ViewChanging;

            if (m_refreshActivated)
            {
                if (this.RefreshRequested != null)
                {
                    RefreshRequestedEventArgs refreshRequestedEventArgs = new RefreshRequestedEventArgs(
                        this.AutoRefresh ? new DeferralCompletedHandler(RefreshCompleted) : null);
                    this.RefreshRequested(this, refreshRequestedEventArgs);
                    if (this.AutoRefresh)
                    {
                        m_scrollerContent.ManipulationMode = ManipulationModes.None;
                        if (!refreshRequestedEventArgs.WasDeferralRetrieved)
                        {
                            // The Deferral object was not retrieved in the event handler.
                            // Animate the content up right away.
                            this.RefreshCompleted();
                        }
                    }
                }

                if (this.RefreshCommand != null && this.RefreshCommand.CanExecute(null))
                {
                    this.RefreshCommand.Execute(null);
                }
            }

            m_isAutoRefreshing = false;
            m_refreshActivated = false;
            m_lastRefreshActivation = default(DateTime);

            this.UpdateCompositionAnimations();
            if (m_scrollerContent.ManipulationMode == ManipulationModes.System)
            {
                this.UpdateRefreshableStatus(m_scroller.VerticalOffset < INITIAL_VERTICALOFFSET_THRESHOLD /*refreshActivatable*/, m_scroller.VerticalOffset < INITIAL_VERTICALOFFSET_THRESHOLD /*force*/);
            }
        }