/// <summary>
 /// Removes the item.
 /// </summary>
 /// <param name="item">The item.</param>
 public void RemoveItem(RadzenAccordionItem item)
 {
     if (items.Contains(item))
     {
         items.Remove(item);
         if (!disposed)
         {
             try { InvokeAsync(StateHasChanged); } catch { }
         }
     }
 }
 async System.Threading.Tasks.Task CollapseAll(RadzenAccordionItem item)
 {
     if (!Multiple && items.Count > 1)
     {
         foreach (var i in items.Where(i => i != item))
         {
             var itemIndex = items.IndexOf(i);
             if (expandedIdexes.Contains(itemIndex))
             {
                 expandedIdexes.Remove(itemIndex);
                 await Collapse.InvokeAsync(items.IndexOf(i));
             }
         }
     }
 }
        /// <summary>
        /// Adds the item.
        /// </summary>
        /// <param name="item">The item.</param>
        public void AddItem(RadzenAccordionItem item)
        {
            if (items.IndexOf(item) == -1)
            {
                if (item.Selected)
                {
                    SelectedIndex = items.Count;
                    if (!Multiple)
                    {
                        expandedIdexes.Clear();
                    }

                    if (!expandedIdexes.Contains(SelectedIndex))
                    {
                        expandedIdexes.Add(SelectedIndex);
                    }
                }

                items.Add(item);
                StateHasChanged();
            }
        }
        internal async System.Threading.Tasks.Task SelectItem(RadzenAccordionItem item)
        {
            await CollapseAll(item);

            var itemIndex = items.IndexOf(item);

            if (!expandedIdexes.Contains(itemIndex))
            {
                expandedIdexes.Add(itemIndex);
                await Expand.InvokeAsync(itemIndex);
            }
            else
            {
                expandedIdexes.Remove(itemIndex);
                await Collapse.InvokeAsync(itemIndex);
            }

            if (!Multiple)
            {
                SelectedIndex = itemIndex;
            }

            StateHasChanged();
        }
 /// <summary>
 /// Determines whether the specified index is selected.
 /// </summary>
 /// <param name="index">The index.</param>
 /// <param name="item">The item.</param>
 /// <returns><c>true</c> if the specified index is selected; otherwise, <c>false</c>.</returns>
 protected bool IsSelected(int index, RadzenAccordionItem item)
 {
     return(expandedIdexes.Contains(index));
 }