private void NavBarItems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs args) { if (args.Action != NotifyCollectionChangedAction.Add) { return; } foreach (NavBarItem item in args.NewItems) { NavBar.AddItem(item); FixedNavBar.AddItem(item); } }
public CollapsiblePage() { InitializeComponent(); NavBar = new NavBar { TitleOpacity = 0, Page = this, BindingContext = this, }; FixedNavBar = new NavBar { Opacity = 0, Page = this, BindingContext = this }; headerLayout.Children.Add(NavBar); fixedLayout.Children.Add(FixedNavBar); var navBarItems = new ObservableCollection <NavBarItem>(); navBarItems.CollectionChanged += NavBarItems_CollectionChanged; NavBarItems = navBarItems; scrollView.Scrolled += Scrolled; scrollView.TouchDown += ScrollView_TouchDown; scrollView.TouchUp += ScrollView_TouchUp; contentLayout.SizeChanged += ContentLayout_SizeChanged; PropertyChanged += OnAnyPropertyChanged; var keyboardService = DependencyService.Get <IKeyboardService>(); keyboardService.KeyboardIsShown += KeyboardService_KeyboardIsShown; keyboardService.KeyboardIsHidden += KeyboardService_KeyboardIsHidden; }