コード例 #1
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            Main                       = GetTemplateChild("Main") as ScrollViewer;
            Root                       = GetTemplateChild("Root") as RelativePanel;
            Indicator                  = GetTemplateChild("Indicator") as Grid;
            IndicatorTransform         = GetTemplateChild("IndicatorTransform") as CompositeTransform;
            IndicatorRing              = GetTemplateChild("IndicatorRing") as ProgressRing;
            IndicatorOverlayBackground = GetTemplateChild("IndicatorOverlayBackground") as Ellipse;
            IndicatorIn                = Root.Resources["IndicatorIn"] as Storyboard;
            IndicatorOut               = Root.Resources["IndicatorOut"] as Storyboard;
            IndicatorOverlayIn         = Root.Resources["IndicatorOverlayIn"] as Storyboard;
            IndicatorOverlayOut        = Root.Resources["IndicatorOverlayOut"] as Storyboard;
            RefreshStartAni            = Root.Resources["RefreshStart"] as Storyboard;
            RefreshCompleteAni         = Root.Resources["RefreshComplete"] as Storyboard;
            Main.ViewChanged          += Main_ViewChanged;
            Root.Loaded               += Root_Loaded1;
            scaleFactor                = 2 * DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;

            if (ForceEnabled || InteractionHelper.HaveTouchCapabilities() || Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                Root.ManipulationDelta   += Root_ManipulationDelta;
                Root.Loaded              += Root_Loaded;
                Root.PointerPressed      += Root_PointerPressed;
                Root.PointerReleased     += Root_PointerReleased;
                Root.PointerCanceled     += Root_PointerReleased;
                Root.PointerCaptureLost  += Root_PointerReleased;
                Root.PointerExited       += Root_PointerReleased;
                Main.VerticalScrollMode   = ScrollMode.Disabled;
                Main.PointerWheelChanged += Main_PointerWheelChanged;
            }
            else
            {
                Main.VerticalScrollMode = ScrollMode.Enabled;
                Indicator.Visibility    = Visibility.Collapsed;
                Main.ManipulationMode   = ManipulationModes.None;
            }
        }