private void RegisterAccordionItem(AccordionItem item) { item.ArrowVisibility = ShowArrow ? Visibility.Visible : Visibility.Hidden; item.Collapse(); item.OnExpandedEvent += OnAccordionItemExpanded; item.OnCollapsedEvent += OnAccordionItemCollapsed; }
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(); } } } } }
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(); }
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; } } }
public ToggleCommand(AccordionItem owner) { this.owner = owner; }