private void DropItem(LuiAccordionItem source, LuiAccordionItem target) { if (GetList() is System.Collections.IList list) { MoveItem(list, source, target); } }
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); }
private void CollapseAllItems(LuiAccordionItem sender) { foreach (var item in Items) { if (item != sender.DataContext) { if (ItemContainerGenerator.ContainerFromItem(item) is LuiAccordionItem itemContainer) { itemContainer.IsExpanded = false; } } } }
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); }
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; } }