當前位置: 首頁>>代碼示例>>C#>>正文


C# ScrollViewer.AddHandler方法代碼示例

本文整理匯總了C#中Windows.UI.Xaml.Controls.ScrollViewer.AddHandler方法的典型用法代碼示例。如果您正苦於以下問題:C# ScrollViewer.AddHandler方法的具體用法?C# ScrollViewer.AddHandler怎麽用?C# ScrollViewer.AddHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Windows.UI.Xaml.Controls.ScrollViewer的用法示例。


在下文中一共展示了ScrollViewer.AddHandler方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnApplyTemplate

        /// <summary>
        /// Invoked whenever application code or internal processes (such as a rebuilding
        /// layout pass) call <see cref="OnApplyTemplate"/>. In simplest terms, this means the method
        /// is called just before a UI element displays in an application. Override this
        /// method to influence the default post-template logic of a class.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            m_root = this.GetTemplateChild(PART_ROOT) as UIElement;
            m_scroller = this.GetTemplateChild(PART_SCROLLER) as ScrollViewer;
            m_scrollerContent = this.GetTemplateChild(PART_SCROLLER_CONTENT) as UIElement;
            m_refreshIndicatorContainer = this.GetTemplateChild(PART_REFRESH_INDICATOR) as FrameworkElement;
            m_defaultRefreshIndicatorTextBlock = this.GetTemplateChild(PART_DEFAULT_REFRESH_INDICATOR_CONTENT) as TextBlock;

            if (m_root != null &&
                m_scroller != null &&
                m_scrollerContent != null &&
                m_refreshIndicatorContainer != null)
            {
                m_scroller.DirectManipulationStarted += Scroller_DirectManipulationStarted;
                m_scroller.DirectManipulationCompleted += Scroller_DirectManipulationCompleted;
                m_scroller.ViewChanged += Scroller_ViewChanged;
                m_scroller.AddHandler(UIElement.PointerPressedEvent, new PointerEventHandler(Scroller_PointerPressed), true);

                // In AutoRefresh mode, zoom factors smaller or larger than 1.0 are not supported.
                if (this.AutoRefresh)
                {
                    m_scroller.MinZoomFactor = 1.0f;
                    m_scroller.MaxZoomFactor = 1.0f;
                    m_scroller.ZoomMode = ZoomMode.Disabled;
                }

                m_refreshIndicatorContainer.SizeChanged += RefreshIndicatorContainer_SizeChanged;
            }

            if (m_defaultRefreshIndicatorTextBlock != null)
            {
                m_defaultRefreshIndicatorTextBlock.Visibility = this.RefreshIndicatorContent == null ? Visibility.Visible : Visibility.Collapsed;
            }

            base.OnApplyTemplate();
        }
開發者ID:AJ-COOL,項目名稱:Windows-universal-samples,代碼行數:42,代碼來源:RefreshableListView.cs

示例2: OnApplyTemplate

        /// <summary>
        /// Builds the visual tree for the <see cref="T:System.Windows.Controls.ListBox"/>
        /// control when a new template is applied.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            if (ElementScrollViewer != null)
            {
                //				ElementScrollViewer.MouseMove -= viewer_MouseMove;
                ElementScrollViewer.DragEnter -= ElementScrollViewer_DragEnter;
                //ElementScrollViewer.ManipulationStarted -= ElementScrollViewer_ManipulationStarted;
                //ElementScrollViewer.ManipulationCompleted -= viewer_ManipulationCompleted;
                ElementScrollViewer.RemoveHandler(ManipulationStartedEvent, new EventHandler<ManipulationStartedEventArgs>(this.ElementScrollViewer_ManipulationStarted));
                ElementScrollViewer.RemoveHandler(ManipulationCompletedEvent, new EventHandler<ManipulationCompletedEventArgs>(this.viewer_ManipulationCompleted));
            }
            ElementScrollViewer = GetTemplateChild("ScrollViewer") as Windows.UI.Xaml.Controls.ScrollViewer;
            if (ElementScrollViewer != null)
            {
                ElementScrollViewer.DragEnter += ElementScrollViewer_DragEnter;
                //ElementScrollViewer.MouseMove += viewer_MouseMove;
                //ElementScrollViewer.ManipulationStarted += ElementScrollViewer_ManipulationStarted;
                //ElementScrollViewer.ManipulationCompleted += viewer_ManipulationCompleted;
                ElementScrollViewer.AddHandler(ManipulationStartedEvent, new EventHandler<ManipulationStartedEventArgs>(this.ElementScrollViewer_ManipulationStarted), true);
                ElementScrollViewer.AddHandler(ManipulationCompletedEvent, new EventHandler<ManipulationCompletedEventArgs>(this.viewer_ManipulationCompleted), true);
            }
            ElementRelease = GetTemplateChild("ReleaseElement") as UIElement;

            StateDescription = GetTemplateChild("StateDescription") as TextBlock;
            UpdateDescription = GetTemplateChild("UpdateDescription") as TextBlock;

            ChangeVisualState(RefreshState.Pulling, false);
            //GoToState("Pulling", false);
        }
開發者ID:HppZ,項目名稱:UniversalTest,代碼行數:34,代碼來源:PullToFresh.cs


注:本文中的Windows.UI.Xaml.Controls.ScrollViewer.AddHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。