public void SetElement(VisualElement element) { if (element != null && !(element is TabbedPage)) { throw new ArgumentException("Element must be a TabbedPage", "element"); } TabbedPage oldElement = Element; Element = (TabbedPage)element; if (oldElement != null) { oldElement.PropertyChanged -= OnElementPropertyChanged; ((INotifyCollectionChanged)oldElement.Children).CollectionChanged -= OnPagesChanged; } if (element != null) { if (Control == null) { Control = new FormsPivot { Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["TabbedPageStyle"] }; Control.HeaderTemplate = (Windows.UI.Xaml.DataTemplate)Windows.UI.Xaml.Application.Current.Resources["TabbedPageHeader"]; Control.ItemTemplate = (Windows.UI.Xaml.DataTemplate)Windows.UI.Xaml.Application.Current.Resources["TabbedPage"]; Control.SelectionChanged += OnSelectionChanged; Tracker = new BackgroundTracker <Pivot>(Windows.UI.Xaml.Controls.Control.BackgroundProperty) { Element = (Page)element, Control = Control, Container = Control }; Control.Loaded += OnLoaded; Control.Unloaded += OnUnloaded; } Control.DataContext = Element; OnPagesChanged(Element.Children, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); UpdateCurrentPage(); UpdateBarTextColor(); UpdateBarBackgroundColor(); ((INotifyCollectionChanged)Element.Children).CollectionChanged += OnPagesChanged; element.PropertyChanged += OnElementPropertyChanged; if (!string.IsNullOrEmpty(element.AutomationId)) { Control.SetValue(AutomationProperties.AutomationIdProperty, element.AutomationId); } } OnElementChanged(new VisualElementChangedEventArgs(oldElement, element)); }
public void SetElement(VisualElement element) { if (element != null && !(element is TabbedPage)) { throw new ArgumentException("Element must be a TabbedPage", "element"); } var oldElement = Page; Element = element; if (oldElement != null) { oldElement.PropertyChanged -= OnElementPropertyChanged; ((INotifyCollectionChanged)oldElement.Children).CollectionChanged -= OnPagesChanged; } if (element != null) { if (_tracker == null) { _tabs = new TabsControl(); _canvas = new Canvas(); _canvas.ChildrenTransitions = new TransitionCollection { new EntranceThemeTransition() }; Tracker = new BackgroundTracker <Canvas>(Panel.BackgroundProperty) { Element = (Page)element, Control = _canvas, Container = _canvas }; _canvas.Loaded += OnLoaded; _canvas.Unloaded += OnUnloaded; } _tabs.DataContext = element; OnPagesChanged(Page.Children, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); UpdateCurrentPage(); UpdateBarTextColor(); UpdateBarBackgroundColor(); ((INotifyCollectionChanged)Page.Children).CollectionChanged += OnPagesChanged; element.PropertyChanged += OnElementPropertyChanged; } OnElementChanged(new VisualElementChangedEventArgs(oldElement, element)); }
public void SetElement(VisualElement element) { if (element != null && !(element is MasterDetailPage)) { throw new ArgumentException("Element must be a Page", "element"); } MasterDetailPage oldElement = Element; Element = (MasterDetailPage)element; if (oldElement != null) { oldElement.PropertyChanged -= OnElementPropertyChanged; } if (element != null) { if (_container == null) { _container = new MasterDetailControl(); _container.UserClosedPopover += OnUserClosedPopover; _container.SizeChanged += OnNativeSizeChanged; Tracker = new BackgroundTracker <PageControl>(Control.BackgroundProperty) { Element = (Page)element, Container = _container }; _container.Loaded += OnLoaded; _container.Unloaded += OnUnloaded; } element.PropertyChanged += OnElementPropertyChanged; UpdateBehavior(); SetMaster(Element.Master); SetDetail(Element.Detail); UpdateIsPresented(); } OnElementChanged(new VisualElementChangedEventArgs(oldElement, element)); }