コード例 #1
0
ファイル: LuiAccordion.xaml.cs プロジェクト: q2g/leonardo-wpf
 private void DropItem(LuiAccordionItem source, LuiAccordionItem target)
 {
     if (GetList() is System.Collections.IList list)
     {
         MoveItem(list, source, target);
     }
 }
コード例 #2
0
ファイル: LuiAccordion.xaml.cs プロジェクト: q2g/leonardo-wpf
 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);
 }
コード例 #3
0
ファイル: LuiAccordion.xaml.cs プロジェクト: q2g/leonardo-wpf
 private void CollapseAllItems(LuiAccordionItem sender)
 {
     foreach (var item in Items)
     {
         if (item != sender.DataContext)
         {
             if (ItemContainerGenerator.ContainerFromItem(item) is LuiAccordionItem itemContainer)
             {
                 itemContainer.IsExpanded = false;
             }
         }
     }
 }
コード例 #4
0
ファイル: LuiAccordion.xaml.cs プロジェクト: q2g/leonardo-wpf
        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);
        }
コード例 #5
0
ファイル: LuiAccordion.xaml.cs プロジェクト: q2g/leonardo-wpf
        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;
            }
        }