示例#1
0
 private void RegisterAccordionItem(AccordionItem item)
 {
     item.ArrowVisibility = ShowArrow ? Visibility.Visible : Visibility.Hidden;
     item.Collapse();
     item.OnExpandedEvent  += OnAccordionItemExpanded;
     item.OnCollapsedEvent += OnAccordionItemCollapsed;
 }
示例#2
0
 void OnAccordionItemExpanded(AccordionItem expandedItem)
 {
     foreach (var item in Items)
     {
         var accordionItem = item as AccordionItem;
         if (accordionItem != null)
         {
             if (expandedItem != accordionItem)
             {
                 if (accordionItem.IsExpanded)
                 {
                     accordionItem.Collapse();
                 }
             }
         }
     }
 }
示例#3
0
        void OnAccordionItemCollapsed(AccordionItem collapsedItem)
        {
            foreach (var item in Items)
            {
                var accordionItem = item as AccordionItem;
                if (accordionItem != null)
                {
                    if (collapsedItem != accordionItem)
                    {
                        if (accordionItem.IsExpanded)
                        {
                            return;
                        }
                    }
                }
            }

            collapsedItem.Expand();
        }
示例#4
0
        private void OnControlLoaded(object sender, RoutedEventArgs e)
        {
            var nonAccordionItems = new List <object>();

            foreach (var item in Items)
            {
                var accordionItem = item as AccordionItem;
                if (accordionItem != null)
                {
                    RegisterAccordionItem(accordionItem);
                }
                else
                {
                    nonAccordionItems.Add(item);
                }
            }

            foreach (var item in nonAccordionItems)
            {
                Items.Remove(item); // remove from items

                // create accordion item for it
                var newAccordionItem = new AccordionItem
                {
                    Content = item,
                    Header  = new TextBlock()
                };
                Items.Add(newAccordionItem);
                RegisterAccordionItem(newAccordionItem);
            }

            foreach (var item in Items)
            {
                var accordionItem = item as AccordionItem;
                if (accordionItem != null)
                {
                    accordionItem.Expand();
                    break;
                }
            }
        }
示例#5
0
 public ToggleCommand(AccordionItem owner)
 {
     this.owner = owner;
 }