protected override void OnApplyTemplate() { base.OnApplyTemplate(); if (UseCompositionAPI) { _header = GetTemplateChild("Header") as ContentControl; _headerBorder = GetTemplateChild("HeaderBorder") as Border; _header.DataContext = this; _content = GetTemplateChild("Content") as ContentPresenter; _content.Loaded += _content_Loaded; } else { _header = GetTemplateChild(PanelHeader) as ContentControl; _content = GetTemplateChild(PanelContent) as ContentPresenter; _scrollViewer = GetTemplateChild(ScrollViewer) as ScrollViewer; _innerCustomPanel = GetTemplateChild(InnerCustomPanel) as ScrollPanel; _header.DataContext = this; _innerCustomPanel.SizeChanged += _innerCustomPanel_SizeChanged; _scrollViewer.ViewChanged += _scrollViewer_ViewChanged; _scrollViewer.SizeChanged += _scrollViewer_SizeChanged; _scrollViewer.DirectManipulationStarted += _scrollViewer_DirectManipulationStarted; } }
//public bool IsRefreshing //{ // get { return (bool)GetValue(IsRefreshingProperty); } // set { SetValue(IsRefreshingProperty, value); } //} //// Using a DependencyProperty as the backing store for IsRefreshing. This enables animation, styling, binding, etc... //public static readonly DependencyProperty IsRefreshingProperty = // DependencyProperty.Register("IsRefreshing", typeof(bool), typeof(PullToRefreshPanel), new PropertyMetadata(false)); #endregion protected override void OnApplyTemplate() { _panelHeader = GetTemplateChild(PanelHeader) as ContentControl; _panelContent = GetTemplateChild(PanelContent) as ContentPresenter; _scrollViewer = GetTemplateChild(ScrollViewer) as ScrollViewer; _innerCustomPanel = GetTemplateChild(InnerCustomPanel) as ScrollPanel; base.OnApplyTemplate(); _panelHeader.DataContext = this; _innerCustomPanel.SizeChanged += _innerCustomPanel_SizeChanged; _scrollViewer.ViewChanged += _scrollViewer_ViewChanged; _scrollViewer.SizeChanged += _scrollViewer_SizeChanged; _scrollViewer.DirectManipulationStarted += _scrollViewer_DirectManipulationStarted; }