Ejemplo n.º 1
0
 /// <summary>
 /// Update layout menu items
 /// </summary>
 private void OnMenuItemsSourceCollectionChangedInternal(ItemMenuLayout layout, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         AddItems(e.NewItems, e.NewStartingIndex, layout);
     }
     else if (e.Action == NotifyCollectionChangedAction.Move)
     {
         MoveItems(e.OldItems, e.OldStartingIndex, e.NewStartingIndex, layout);
     }
     else if (e.Action == NotifyCollectionChangedAction.Remove)
     {
         RemoveItems(e.OldItems, e.OldStartingIndex, layout);
     }
     else if (e.Action == NotifyCollectionChangedAction.Replace)
     {
         throw new NotImplementedException("ItemsView: NotifyCollectionChangedAction.Replace not implemented!");
     }
     else if (e.Action == NotifyCollectionChangedAction.Reset)
     {
         RemoveItems(e.OldItems, e.OldStartingIndex, layout);
     }
     else
     {
         throw new Exception("ItemsView: Invalid action!");
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Called when all left menu items changed
        /// </summary>
        private void OnLeftMenuItemsSourceChanged(IList oldSource, IList newSource)
        {
            if (m_leftMenuLayout == null)
            {
                m_leftMenuLayout = new ItemMenuLayout();
                Children.Add(m_leftMenuLayout);
            }

            if (oldSource != null && oldSource.Count > 0)
            {
                OnMenuItemsSourceCollectionChangedInternal(m_leftMenuLayout, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, null));
            }

            if (newSource != null && newSource.Count > 0)
            {
                OnMenuItemsSourceCollectionChangedInternal(m_leftMenuLayout, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, newSource));
            }
        }