Example #1
0
 private void DropItem(LuiAccordionItem source, LuiAccordionItem target)
 {
     if (GetList() is System.Collections.IList list)
     {
         MoveItem(list, source, target);
     }
 }
Example #2
0
 protected override bool IsItemItsOwnContainerOverride(object item)
 {
     try
     {
         if (item is LuiAccordionItem accordionitem)
         {
             if (collapseAllOnExpandSingle)
             {
                 DependencyPropertyDescriptor
                 .FromProperty(LuiAccordionItem.IsExpandedProperty, typeof(LuiAccordionItem))
                 .AddValueChanged(accordionitem, IsExpandedChanged);
             }
             if (accordionitem.IsExpanded)
             {
                 expandedItem = accordionitem;
             }
             return(true);
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex);
     }
     return(false);
 }
Example #3
0
 private void CollapseAllItems(LuiAccordionItem sender)
 {
     foreach (var item in Items)
     {
         if (item != sender.DataContext)
         {
             if (ItemContainerGenerator.ContainerFromItem(item) is LuiAccordionItem itemContainer)
             {
                 itemContainer.IsExpanded = false;
             }
         }
     }
 }
Example #4
0
        protected override DependencyObject GetContainerForItemOverride()
        {
            var retval = new LuiAccordionItem();

            try
            {
                if (collapseAllOnExpandSingle)
                {
                    DependencyPropertyDescriptor
                    .FromProperty(LuiAccordionItem.IsExpandedProperty, typeof(LuiAccordionItem))
                    .AddValueChanged(retval, IsExpandedChanged);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            return(retval);
        }
Example #5
0
        private void MoveItem(System.Collections.IList list, LuiAccordionItem source, LuiAccordionItem target)
        {
            int sourceIndex     = ItemContainerGenerator.IndexFromContainer(source);
            int targetIndex     = ItemContainerGenerator.IndexFromContainer(target);
            int sortindexsource = source.Index;
            int sortindextarget = target.Index;

            if (isDragDropChangesUnderlyingCollection)
            {
                object valueToMove = list[sourceIndex];
                if (sourceIndex != targetIndex)
                {
                    if (list is ObservableCollection <object> olist)
                    {
                        olist.Move(sourceIndex, targetIndex);
                    }
                    else
                    {
                        list.RemoveAt(sourceIndex);
                        list.Insert(targetIndex, valueToMove);
                    }

                    AdjustIndexes(list, sortindexsource, sortindextarget);

                    if (ItemContainerGenerator.ContainerFromItem(valueToMove) is LuiAccordionItem movedItemContainer)
                    {
                        movedItemContainer.Index = sortindextarget;
                    }
                }
            }
            else
            {
                AdjustIndexes(list, sortindexsource, sortindextarget);
                source.Index = sortindextarget;
            }
        }