Class MenuItemCollection
- Namespace
- SharpConsoleUI.Controls
- Assembly
- SharpConsoleUI.dll
Observable collection of MenuItems used for both MenuItem.Children and MenuControl.Items. Overrides ClearItems so Clear() fires actionable Remove events per item — the base ObservableCollection only fires a single Reset with no OldItems, which would prevent MenuControl from detaching items and disposing their bindings.
public sealed class MenuItemCollection : ObservableCollection<MenuItem>, IList<MenuItem>, ICollection<MenuItem>, IReadOnlyList<MenuItem>, IReadOnlyCollection<MenuItem>, IEnumerable<MenuItem>, IList, ICollection, IEnumerable, INotifyCollectionChanged, INotifyPropertyChanged
- Inheritance
-
MenuItemCollection
- Implements
- Inherited Members
- Extension Methods
Constructors
MenuItemCollection()
Creates a top-level collection (no owning MenuItem).
public MenuItemCollection()
MenuItemCollection(MenuItem?)
Creates a Children collection owned by the given MenuItem.
public MenuItemCollection(MenuItem? ownerItem)
Parameters
ownerItemMenuItem
Properties
OwnerItem
The MenuItem whose Children this collection represents, or null when this collection is the top-level MenuControl.Items. Used to assign Parent on newly-added items in O(1).
public MenuItem? OwnerItem { get; }
Property Value
Methods
ClearItems()
Removes all items from the collection.
protected override void ClearItems()