public override void OnApplyTemplate() { if (_content != null) { _content.ContentVisible -= OnContentVisible; _content.ContentHidden -= OnContentHidden; } base.OnApplyTemplate(); _content = GetTemplateChild(LoadingContentControlName) as LoadingContentControl; if (_content != null) { _content.ContentVisible += OnContentVisible; _content.ContentHidden += OnContentHidden; } if (_pivot == null) { DependencyObject d = Parent; while (d != null && !(d is Pivot)) { d = VisualTreeHelper.GetParent(d); } _pivot = d as Pivot; if (_pivot == null) { return; } if (_content != null) { _content.ReleaseContentTree = GetIsMemoryEfficient(_pivot); } _pivot.SelectionChanged += OnPivotSelectionChanged; // TODO: this was more efficient before _pivot.LoadedPivotItem += OnLoadedPivotItem; _pivot.UnloadingPivotItem += OnUnloadingPivotItem; if (_pivot.SelectedItem == this && _content != null) { Dispatcher.BeginInvoke(_content.Load); } } }
public override void OnApplyTemplate() { if (_content != null) { _content.ContentVisible -= OnContentVisible; _content.ContentHidden -= OnContentHidden; } base.OnApplyTemplate(); _content = GetTemplateChild(LoadingContentControlName) as LoadingContentControl; if (_content != null) { _content.ContentVisible += OnContentVisible; _content.ContentHidden += OnContentHidden; } if (_pivot == null) { DependencyObject d = Parent; while (d != null && !(d is Pivot)) { d = VisualTreeHelper.GetParent(d); } _pivot = d as Pivot; if (_pivot == null) { return; } if (_content != null) { _content.ReleaseContentTree = GetIsMemoryEfficient(_pivot); } _pivot.SelectionChanged += OnPivotSelectionChanged; // TODO: this was more efficient before _pivot.LoadedPivotItem += OnLoadedPivotItem; _pivot.UnloadingPivotItem += OnUnloadingPivotItem; if (_pivot.SelectedItem == this && _content != null) { Dispatcher.BeginInvoke(_content.Load); } } }