BindableApplicationBar.BindableApplicationBar.MenuItemsCollectionChanged C# (CSharp) Method

MenuItemsCollectionChanged() private method

private MenuItemsCollectionChanged ( object sender, NotifyCollectionChangedEventArgs e ) : void
sender object
e System.Collections.Specialized.NotifyCollectionChangedEventArgs
return void
        private void MenuItemsCollectionChanged(
            object sender, NotifyCollectionChangedEventArgs e)
        {
            if (this.applicationBar == null)
            {
                return;
            }

            if (e.OldItems != null)
            {
                foreach (var oldItem in e.OldItems)
                {
                    this.DetachMenuItem(
                        (BindableApplicationBarMenuItem)oldItem);
                }
            }

            if (e.NewItems != null)
            {
                int i = 0;

                foreach (var newItem in e.NewItems)
                {
                    this.AttachMenuItem(
                        (BindableApplicationBarMenuItem)newItem,
                        e.NewStartingIndex + i++);
                }
            }
        }
        #endregion