public override void OnApplyTemplate() { base.OnApplyTemplate(); HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch; _templateRoot = MoreVisualTreeExtensions.FindFirstChildOfType <Panel>(this); if (_templateRoot == null) { throw new InvalidOperationException("Must include a Panel in the root of the template."); } if (!_transitionedIn) { var @in = GetTransitionIn(); if (@in != null && _templateRoot != null) { var transition = @in.GetTransition(_templateRoot); transition.Completed += (x, xe) => transition.Stop(); transition.Begin(); } _transitionedIn = true; } }
public override void OnApplyTemplate() { if (_button != null) { _button.Click -= OnClick; } base.OnApplyTemplate(); _root = MoreVisualTreeExtensions.FindFirstChildOfType <Grid>(this); if (null == _root) { throw new NotSupportedException("Must include a Grid for manipulating."); } _button = GetTemplateChild("_button") as Button; if (_button != null) { _button.Click += OnClick; } TransformAnimator.EnsureAnimator(_root, ref _ta); OpacityAnimator.EnsureAnimator(_root, ref _oa); if (_oa != null) { _root.Opacity = 0; _oa.GoTo(1.0, new Duration(TimeSpan.FromSeconds(.5))); } }
public override void OnApplyTemplate() { if (_image != null) { _image.FinalImageAvailable -= OnFinalImageAvailable; } base.OnApplyTemplate(); _image = MoreVisualTreeExtensions.FindFirstChildOfType <SmoothImage>(this); if (_image != null) { _image.FinalImageAvailable += OnFinalImageAvailable; } UpdateMap(); }
public override void OnApplyTemplate() { _templateApplied = true; base.OnApplyTemplate(); _stack = MoreVisualTreeExtensions.FindFirstChildOfType <Panel>(this); if (!_haveItems) { UpdateItems(); } if (double.IsNaN(MinimumItemHeight) || MinimumItemHeight < 1) { #if DEBUG_GIC Debug.WriteLine(""); Debug.WriteLine("<< Developer: You should set the minimum item height for this control. " + Name + ">>"); Debug.WriteLine(""); #endif // Just an approximate for initial stack panel population. MinimumItemHeight = 50; } }
public override void OnApplyTemplate() { if (_scrollViewer != null && IsPullToRefreshEnabled) { _scrollViewer.ManipulationStarted -= OnManipulationStarted; } if (_top != null) { _top.MouseLeftButtonDown -= OnJumpToTop; } if (_bottom != null) { _bottom.MouseLeftButtonDown -= OnJumpToBottom; } _ta = null; base.OnApplyTemplate(); if (IsPullToRefreshEnabled) { SizeChanged += OnSizeChanged; } _scrollViewer = MoreVisualTreeExtensions.FindFirstChildOfType <ScrollViewer>(this); if (null == _scrollViewer) { return; // Must be at design time. //throw new NotSupportedException("Control Template must include a ScrollViewer."); } Dispatcher.BeginInvoke(() => { _top = VisualTreeExtensions.GetVisualDescendants(_scrollViewer).OfType <Rectangle>().Where(b => b.Name == TopJumpName).FirstOrDefault(); _bottom = VisualTreeExtensions.GetVisualDescendants(_scrollViewer).OfType <Rectangle>().Where(b => b.Name == BottomJumpName).FirstOrDefault(); if (_top != null) { _top.MouseLeftButtonUp += OnJumpToTop; } if (_bottom != null) { _bottom.MouseLeftButtonUp += OnJumpToBottom; } }); _header = GetTemplateChild("Header") as ContentPresenter; if (_header != null) { TransformYAnimator.EnsureAnimator(_header, ref _ta); } if (IsPullToRefreshEnabled) { _scrollViewer.ManipulationStarted += OnManipulationStarted; } Dispatcher.BeginInvoke(() => { int i = 0; UIElement uie = Parent as UIElement; while (i < 8 && uie != null && _piv == null) { uie = VisualTreeHelper.GetParent(uie) as UIElement; _piv = uie as LoadingPivotItem; } var implroot = VisualTreeHelper.GetChild(_scrollViewer, 0) as FrameworkElement; if (implroot != null) { VisualStateGroup group = FindVisualState(implroot, "ScrollStates"); if (group != null) { group.CurrentStateChanging += OnScrollingStateChanging; // should probably disconnect too } } this.InvokeOnLayoutUpdated(Bump); }); }